Partial matching GAE search API

后端 未结 6 827
日久生厌
日久生厌 2020-11-28 09:35

Using the GAE search API is it possible to search for a partial match?

I\'m trying to create autocomplete functionality where the term would be a partial word. eg.

6条回答
  •  遥遥无期
    2020-11-28 10:12

    My version optimized: not repeat tokens

    def tokenization(text):
        a = []
        min = 3
        words = text.split()
        for word in words:
            if len(word) > min:
                for i in range(min, len(word)):
                    token = word[0:i]
                    if token not in a:
                        a.append(token)
        return a
    

提交回复
热议问题