简体   繁体   English

Elasticsearch搜索查询选择

[英]Elasticsearch search query selection

I'd like to search terms (GoogleEarth or googleearch) using elasticSearch. 我想使用elasticSearch搜索字词(GoogleEarth或googleearch)。
Now if I tried to search query 'Google', I cannot get any results without NGram or EdgeNGram. 现在,如果我尝试搜索查询“ Google”,那么如果没有NGram或EdgeNGram,我将无法获得任何结果。
I don't want to use nGram because they get a lot of results. 我不想使用nGram,因为它们会得到很多结果。 So now I just use Bool Query + multimatchquery. 所以现在我只使用Bool Query + multimatchquery。 At this case, I cannot get results by partial words. 在这种情况下,我无法通过部分单词获得结果。 I hope I can search 'Google Earth' or 'Google' or 'Earth' to get GoogleEarth. 我希望我可以搜索“ Google Earth”或“ Google”或“ Earth”来获取GoogleEarth。 How can I get this? 我怎么能得到这个?

Now I just use query 'GoogleEarth' to get right result. 现在,我只是使用查询“ GoogleEarth”来获得正确的结果。 I want to search terms if they included. 我想搜索包含的术语。

 .setQuery(QueryBuilders.boolQuery().should(QueryBuilders.multiMatchQuery(query,
                               'title','name','tag')))

update 更新

I tried to search terms based on exact match. 我试图根据完全匹配来搜索字词。 If I search 'google', i want to get 'google***' 'googleearth' and so on. 如果我搜索“ google”,我想获得“ google ***”“ googleearth”,依此类推。 I know if I use edgeNGram or nGram, i may get less related results. 我知道如果使用edgeNGram或nGram,可能会得到较少的相关结果。 So if possible, I don't want to use nGram or edgeNGram. 因此,如果可能的话,我不想使用nGram或edgeNGram。 Do you have any ideas? 你有什么想法?

I think you need to define a custom analyzer to tokenize words based on camel case - ie "GoogleEarth" needs to be tokenized into the parts "Google" and "Earth". 我认为您需要定义一个自定义分析器以基于驼峰大小写对单词进行标记-即,“ GoogleEarth”需要标记为“ Google”和“ Earth”部分。

See the camelcase tokenizer section of http://www.elasticsearch.org/guide/reference/index-modules/analysis/pattern-analyzer/ camelcase tokenizer的部分http://www.elasticsearch.org/guide/reference/index-modules/analysis/pattern-analyzer/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM