I'm trying to search for a document, by field value. The field is of type String that was defined in the index like this:
"field" : {
"type" : "string"
}
There are no other settings to the index but the mappings.
I tried various queries to try to find documents with field="test"
, and every time I get no results or results that contain that substring "test"
. I want the document where "field"
matches "test"
exactly.
I tried match
, match_phrase
, term
and query_string
, none of which seems to work as I want.
You need to use term
query with keyword like this
{
"query" : {
"term" : {
"field.keyword" : "test"
}
}
}
hope this helps.