1. Introduction to term query
The full-text query will parse the query string before execution, but the term level query will operate precisely on the terms stored in the inverted index. These queries are usually used for structured data such as numbers, dates, and enumerations, rather than full-text fields. Or, they allow you to make low-level queries and do so before the analysis process.
2.term query
Term query is used for term search. As mentioned in the previous chapter, it is not repeated here.
3.terms query
Term queries are useful for finding a single value, but often we want to search for multiple values. We only need to use a single term query (note the s at the end). A term query is like the plural form of a term query (compared with the singular and plural forms of an English noun).
The following query "title" contains three phrases: "Hebei", "Changsheng", "country garden".
GET telegraph/_search { "query": { "terms": { "title": ["Hebei","Longevity","Biguiyuan"] } } }
{ "took": 7, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 3, "max_score": 1, "hits": [ { "_index": "telegraph", "_type": "msg", "_id": "A5etp2QBW8hrYY3zGJk7", "_score": 1, "_source": { "title": "Yang Huiyan, vice chairman of Country Garden Group", "content": "Yang Huiyan bought 10 million shares and 15 million shares of country garden on July 10 and 11 respectively", "author": "Small money note", "pubdate": "2018-07-17T16:12:55" } }, { "_index": "telegraph", "_type": "msg", "_id": "Apetp2QBW8hrYY3zGJk7", "_score": 1, "_source": { "title": "Changsheng biology fell again and three institutions sold nearly 10 million yuan", "content": "Changsheng biology fell and stopped again, closing 19.89 RMB 14.32 million", "author": "Longevity organism", "pubdate": "2018-07-17T10:03:11" } }, { "_index": "telegraph", "_type": "msg", "_id": "BJetp2QBW8hrYY3zGJk7", "_score": 1, "_source": { "title": "Hebei focuses on ten industries and promotes international production capacity cooperation", "content": "The Hebei provincial government has recently launched an active participation in the construction of "one belt and one road" to promote the implementation of international capacity cooperation.", "author": "Finance Union", "pubdate": "2018-07-17T14:14:55" } } ] } }
4. Terms set query
5.range query
Range queries are used to match documents with numeric, date, or string fields in a range.