Query match

I am trying to match a query against the value in the "test" field

Following are the documents indexed -

curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
"test" : "routers switches"
}'

curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '{
"test" : "routers"
}'

curl -XPUT 'http://localhost:9200/twitter/tweet/3' -d '{
"test" : "switches hubs"
}'

*User's query - *

curl -XGET http://localhost:9200/twitter/tweet/_search -d '{
"query":
{
"match" : {
"test" : {
"query" : "routers and switches for home"
}
}
}
}'

Desired Output -
document 1 : routers switches
document 2 : routers

I do not want the third document "switches hubs" in the results since it
has hubs which is not part of the user query.

Can somebody help me in a writing a query for this requirement?

Thanks
-dk

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/986a3db5-5645-4527-b647-d797a88fcd4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Have you tried like this?

"query": {
"match": {
"test": {
"query": "routers and switches for home",
"operator": "and"
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bd96b698-5c71-4297-8a23-dc775416a862%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yes, but that wouldn't serve the purpose I was looking for. Using "ÄND"
operator, wouldn't give me any results at all since there are no documents
which has all the words in the User Query.

On Thursday, September 18, 2014 7:22:22 PM UTC+5:30, Ramy wrote:

Have you tried like this?

"query": {
"match": {
"test": {
"query": "routers and switches for home",
"operator": "and"
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8b9fe175-494f-4b5c-9b97-e580c879c4c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.