简体   繁体   English

在使用与Elasticsearch-py匹配的查询时,是否有任何自定义分析器的建议?

[英]Any suggestions to customize an analyzer when using query match with elasticsearch-py?

I can't apply a custom analyzer when using query match with elasticsearch-py. 在对Elasticsearch-py使用查询匹配时,我无法应用自定义分析器。

I customized an analyzer called custom_lowercase_stemmed and used es.indices.put_settings to update the index setting. 我定制了一个名为custom_lowercase_stemmed的分析器,并使用es.indices.put_settings更新了索引设置。

However, it couldn't find the analyzer when I do a search. 但是,我搜索时找不到分析仪。

I also looked into the parameter analyzer in es.search , but it returns an error: 我还查看了es.search的参数analyzer ,但它返回错误:

..unrecognized parameter: [analyzer] ..无法识别的参数:[分析器]

Can I get any suggestions here in terms of a customized analyzer? 我可以从定制分析仪那里获得任何建议吗? Thank you! 谢谢!

query_body = {
     "query": {
         "match": {
            "employer":{
                "query": txt,
                "fuzziness": 'AUTO',
                "analyzer" : 'custom_lowercase_stemmed'
            }
        }
    }
}
es.search(index='hello',body=query_body)

Here is the full error: 这是完整的错误:

RequestError: RequestError(400, 'search_phase_execution_exception', '[match] analyzer [custom_lowercase_stemmed] not found')

I think you have to make sure you have the following: 我认为您必须确保具备以下条件:

  • Have your Configuration set properly. 正确设置您的配置 In your case, you should have in your settings the field "custom_lowercase_stemmed" as analyzer. 在您的情况下,应在设置中将“ custom_lowercase_stemmed”字段用作分析器。 You can also define the words you want to stop. 您还可以定义要停止的单词。

  • With the Python ES Client, you have to send the analyzer as a parameter of the method .search() . 使用Python ES客户端,您必须将分析器作为.search()方法的参数发送。 Check the docs . 检查文档 However, you can try to run your query as it is. 但是,您可以尝试按原样运行查询。 I haven't played that much with analyzer. 我在分析器上玩的不多。

Hope this is helpful! 希望这会有所帮助! :D :D

Ensure that you have specified your analyzer at your mapping and ensure your querying the correct field as well. 确保在映射时指定了分析器,并确保查询正确的字段。

For your question on the matching problem for removing duplicate names, at term level and short words, fuzziness and wildcard parameters would be the best fit! 对于有关删除重复名称的匹配问题的疑问,在术语级别和短词中,模糊性和通配符参数将是最合适的!

Cheers, Min Han (: 干汉(Min Han):

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

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