This article mainly records the use of the basic query API for ESBasic query Type term query
{" query": {"term ": { "title": "Crime"}} }
{"Query": {"term": {" title": { "value": "Crime", "Boost": 10.0 } }}
{" query": {" terms": {" tags": ["Novel", "book"] }}
Common Word Query
Simple understanding is to remove the high privilege of the stop word, divided into two groups to query, such as stop word is high frequency, Cutoff_frequency said that the word below this probability will appear in the low-frequency group.
{"Query": {"common": {"title": {" Query": "Crime and Punishment", "cutoff_frequency": 0.001 } } }}
Match query (Lucene query syntax not supported) query title contains crime or and or punishment documents
{" query": {" match": { "title": "Crime and Punishment"}} }
operator operator
Word breaker that requires and or or matches text
{"Query": {"match": {"title": {" Query": "Crime and Punishment", " Operator": "and" } } }}
Phrase Query
{"Query": {"match_phrase": {"title": {" Query": "Crime punishment", "slop": 1 } } }}
Prefix query
Prefix the last entry of the query keyword
{"Query": {"Match_phrase_prefix": {"title": {" Query": "Crime Punish", "slop": 1, "max_expansions": +}}}
Multi_match (query for multiple fields)
{" query": {" Multi_match": {" query": "Crime Heller", "Fields": ["title", "author"] } }}
Query_string query (supports Lucene query syntax)
The title field contains crime and has a weight of 10, including punishment, but Otitle does not contain a cat, and the colleague author field contains Fyodor and Dostoevsky.
{" query": {" query_string": { "query": "Title:crime^10 +title:punishment-otitle:cat +author: (+fyodor + Dostoevsky) ", " Default_field ":" title "}}
Querying for multiple fields
Use_dis_max using the maximum score, max means that for a given keyword, only the highest score is included in the score of the final document, not all of the field scores that contain the entry.
{" query": {" query_string": {" query": "Crime Heller", "Fields": ["title", "Author"], "Use_dis _max ": True }} }
simple_query_string Query
Parse error without throwing exception, discard query invalid part
{" query": {" simple_query_string": { "query": "Title:crime^10 +title:punishment-otitle:cat +author :(+fyodor +dostoevsky) ", " Default_operator ":" or " } }
Identifier Query
Find using a unique representation of the UID
{" query": {" IDs": {" type": "Book", "values": ["1", "2", "3"] }}}
Prefix query
Prefix matches a given keyword
{" query": {" prefix": { "title": "Cri" }} }
{" query": {"prefix": {" title": { "value": "CRI", "Boost": 3.0 } }}
Fuzzy query
Fuzzy queries using editing distances are computationally significant, but are useful for user-misspelled scenarios
{" query": {" fuzzy": { "title": "Crme"}} }
{"Query": {"fuzzy": {"title": {" value": "Crme", "min_similarity": 1 }}}
Wildcard Query
Support for * and? et wildcard characters
{" query": {" wildcard": { "title": "Cr?me"}} }
Scope Query
Can be for a single field only, numeric, or string-based.
{"Query": {"range": {"Year": { "GTE": 1890, "LTE": 1900 } }}
Regular expression Query
Query performance depends on regular expression
{" query": {"regexp": {" title": { "value": "Cr.m[ae]", "Boost": 10.0 } }}
Boolean query (combined query)
{"Query": {"bool": {"must": {"term ": { "title": "Crime" } }, "should": { ' Range ': { ' year ': {' from ': 1900, ' to ': ' + '}} , ' Must_not ' : {' term ': { "Otitle": "Nothing" } } } }
Use of the basic query API for ES