Elasticsearch: query string in field

Can anyone tell if I am right to check if the title field contains an element


curl -XGET "http://localhost:9200/myapp/item/_search" -d'
{
    "query": {
        "query_string": { 
           "query": "title:Item"
        }
    }
}'

EDIT

I have a name like "Economics and Statistics"

This returns a record


curl -XGET "http://localhost:9200/myapp/item/_search" -d'
{
    "query": {
        "query_string": { 
           "query": "title:*statistics*"
        }
    }
}'

It returns nothing


curl -XGET "http://localhost:9200/myapp/item/_search" -d'
{
    "query": {
        "query_string": { 
           "query": "title:statistics"
        }
    }
}'

This also returns nothing (weird)


curl -XGET "http://localhost:9200/myapp/item/_search" -d'
{
    "query": {
        "query_string": { 
           "query": "title:*Economics*"
        }
    }
}'

Doc says:

where the status field contains the active

status:active
+3
source share
4 answers
you can mention a particular field in default_field

{
    "query_string" : {
        "default_field" : "content",
        "query" : "this AND that OR thus"
    }
}

if you want to specify more than one field then 

{
    "query_string" : {
        "fields" : ["content", "name"],
        "query" : "this AND that"
    }
}
+1
source

For beginners like me, they run into problems with ES: be very careful how you map / label your data. "not_analyzed" does not mean that I thought it meant, and that led me to the problem above.

0
source

. .

curl -XGET "http://localhost:9200/myapp/item/_search" -d'
{
   "query": {
      "term": {
         "title": {
            "value": "Item"
         }
      }
   }
}'

elasticsearch, query_string, . query_string .

-1
source
curl -XGET "http://localhost:9200/myapp/item/_search" -d'
{
    "query": {
        "match": { 
           "title": "statistics"
        }
    }
}'

That would be enough if you want to search for exact terms (not the exact content of the field). Try to avoid using wildcards as this is expensive. To search with a fraction of the word in the field, you need to change the display as necessary.

Check your mapping and see the type of the title field . If it has not been parsed, re-index it as parsed (default).

-1
source

All Articles