How can i do a multiple search query within a single URI in ElasticSearch?

只谈情不闲聊 提交于 2019-12-13 06:30:49

问题


I'm trying to get results of an index, by sending an GET http call from Postman for both date range and for a field ("log_type") which I added manually,

So for now I'm able to get the results, when i query it individually such as:

Date Range: http://localhost:9200/dialog_test/_search?q=timestamp:[2016-08-05+TO+2016-08-06]

log_type: http://localhost:9200/dialog_test/_search?q=log_type:GetProvisioning%20SUCCESS

In the url above (log_type), GetProvisioning Success is a log_type.

So what I wanted to know is, how can I combine both of them into a single query in order to identify, what're the results between a certain date range and with a specific log_type?

Any help could be appreciated


回答1:


You can use AND and OR boolean conjunctions per query strings. In your case, you can do something like:

curl http://localhost:9200/dialog_test/_search?q=timestamp:[2016-08-05+TO+2016-08-06]+AND+log_type:GetProvisioning+SUCCESS



回答2:


Also, you could use the source query string parameter in order to pass the body directly in the URL. For example:

http://localhost:9200/my_index/_search?source={"query": {"match_all": {}},"size": "1","sort": [{"@timestamp": {"order": "desc"}}]}


来源:https://stackoverflow.com/questions/39470511/how-can-i-do-a-multiple-search-query-within-a-single-uri-in-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!