How to match a field exactly

Hey guys. To search for documents that have an exact value in a certain
field, is a query_string query the appropriate solution?

For example, after indexing this document:
{ name : "Super Grimlock", properties : { class: "Deluxe" } }
I can find it like this:
curl 'localhost:9200/test/products/_search' -d '
{ query: { query_string: { fields: ["name"], query: "Super Grimlock"
} } }'

Are there any other ways to perform this search? I've tried term queries
and term filters, but I assume they didn't work because terms aren't
analyzed.

Thanks!
Nick

I just found the "field" query. Eg:

curl 'localhost:9200/test/products/_search' -d '{
query: { field: { name: "Super Grimlock" } }
}'

Are there any other ways?

If you are using default mapping, your field has been tokenized in two terms.
You can use a keyword analyzer in the mapping for that field.

David :wink:
@dadoonet

Le 19 janv. 2012 à 07:40, Nick Hoffman nick@deadorange.com a écrit :

Hey guys. To search for documents that have an exact value in a certain field, is a query_string query the appropriate solution?

For example, after indexing this document:
{ name : "Super Grimlock", properties : { class: "Deluxe" } }
I can find it like this:
curl 'localhost:9200/test/products/_search' -d '
{ query: { query_string: { fields: ["name"], query: "Super Grimlock" } } }'

Are there any other ways to perform this search? I've tried term queries and term filters, but I assume they didn't work because terms aren't analyzed.

Thanks!
Nick

Thanks, David. The keyword analyzer makes a lot of sense.