简体   繁体   English

查询字符串在Elasticsearch扫描和滚动搜索中不起作用

[英]query string doesn't work in elasticsearch scan&scroll search

When I tried: 当我尝试:

curl -XPOST 'http://localhost:9200/index/type/_search?search_type=scan&scroll=2m' -d '{"query": {"match": {"host":"xxxx"}}}'

I got a scroll_id . 我有一个scroll_id Then I issued: 然后我发出:

curl -XPOST 'http://localhost:9200/_search/scroll?scroll=1m&scroll_id=......'

but the response contains logs belonging to other host. 但是响应中包含属于其他主机的日志。 Why and how to solve it? 为什么以及如何解决?

Thanks alot 非常感谢

Try a term query instead of match: 尝试使用字词查询而不是匹配项:

{"query": {"term": {"host":"xxxx"}}}

This would look for the exact value instead of analyzing the value you have for xxxx and a discussion of the differences is: https://www.elastic.co/guide/en/elasticsearch/guide/current/term-vs-full-text.html 这将查找确切的值,而不是分析您对于xxxx的值,并且有关差异的讨论是: https : //www.elastic.co/guide/en/elasticsearch/guide/current/term-vs-full- text.html

If that doesn't work, it could also be that the field is being analyzed, and the mapping would need to be updated as well. 如果这不起作用,也可能是该字段正在被分析,并且映射也需要更新。 Can you share the mapping for the index and type: http://localhost:9200/index/_mapping/type/?pretty ? 您可以共享索引的映射并输入: http:// localhost:9200 / index / _mapping / type /?pretty吗?

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

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