Google app engine 谷歌搜索API-是否可以进行内部查询?
使用搜索API,是否可以执行IN查询?在哪里可以查询包含在字符串数组中的字符串参数的文档?是的,可以按内容查询文档。 有几种可能性,您可以在以下内容中找到此示例:Google app engine 谷歌搜索API-是否可以进行内部查询?,google-app-engine,google-cloud-platform,Google App Engine,Google Cloud Platform,使用搜索API,是否可以执行IN查询?在哪里可以查询包含在字符串数组中的字符串参数的文档?是的,可以按内容查询文档。 有几种可能性,您可以在以下内容中找到此示例: 如果字符串数组太大,使用带有字符串数组的categories数组可以稍微降低成本。可以排除某些类别,这将有助于减少查询处理时间。例如: categories=[['animal','dog','cat','fish'],['positive','good','fine','great'],['negative','horrible'
如果字符串数组太大,使用带有字符串数组的categories数组可以稍微降低成本。可以排除某些类别,这将有助于减少查询处理时间。例如:
categories=[['animal','dog','cat','fish'],['positive','good','fine','great'],['negative','horrible',disgusting','awful'],['water recreation', 'relax','holidays','spa','beach','sea']]
def query_index():
index = search.Index('products')
for categ in categories:
query_string = ' OR '.join(categ)
results = index.search(query_string)
if len(results)>0:
print(categ[0])
break
for scored_document in results:
print(scored_document)
搜索API在操作符中没有
,但可以使用或
操作符模拟。例如,[word1,word2,word3]
中的模式和word\u列表中的模式可以写成:
index.search('word1 OR word2 OR word3')
分别是:
index.search(' OR '.join(word_list))
你是如何看待这个可能包含1000-5000个“单词”的数组的?(数组最大值)。你认为在查找中会有性能下降吗?我没有使用搜索API,但我猜性能会显著下降。或
操作成本较高,请参阅。也许是因为不支持
中的。
index.search('word1 OR word2 OR word3')
index.search(' OR '.join(word_list))