Query Based on Filter Conditions
The query operation on Elasticsearch includes query or filter. In query mode, the score of each returned document is calculated and the scores are sorted by default. In filter mode, only the documents that meet the requirements are filtered and the score is not calculated. In addition, the documents can be cached.
For non-full-text search scenarios, if you do not care about the correlation between query results and query conditions but want to search for target data, you can use the filter mode to improve query efficiency.
The following is an example of query in security mode:
curl -XGET --tlsv1.2 --negotiate -k -u : "https://ip:httpport/myindex-001/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "match": { "age": "56" } } }'
The following is an example of filter in security mode:
curl -XGET --tlsv1.2 --negotiate -k -u : "https://ip:httpport/myindex-001/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "bool": { "filter": { "match": { "age": "56" } } } } }'
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot