How to Filter the serach in elasticsearch


(Mahesh Chary) #1

Hi ,
i have some indexed fields like: { text:some text, id:123,
author:mahesh },{ text:some text, id:124, author:rajesh }.........{},i
want to search a "word" from the object where author is mahesh not in other
objects by elasticsearch using node ...please help me how to prepare a
query object.

currently i am using this query which returns matches from all indexed
fields but i want to search a keyword in a particular author

query:

{"query" : {
term:{text:"grade"}
}

}

--
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/4258c8fb-c552-42c8-82d1-1391929bcf5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Herbert Bodner) #2

You need a Filter query in conjunction the query, see:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html

something like this, Though, I am not sure, if this is entirely correct,
but you get the idea:

{
"filtered" : {
"query" : {
"term" : { "author" : "myauthor" }
},
"filter" : {
"term" : {
"text" : "grade" }
}
}
}
}

On Monday, March 24, 2014 9:54:40 AM UTC+1, Mahesh Chary wrote:

Hi ,
i have some indexed fields like: { text:some text, id:123,
author:mahesh },{ text:some text, id:124, author:rajesh }.........{},i
want to search a "word" from the object where author is mahesh not in other
objects by elasticsearch using node ...please help me how to prepare a
query object.

currently i am using this query which returns matches from all indexed
fields but i want to search a keyword in a particular author

query:

{"query" : {
term:{text:"grade"}
}

}

--
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/52d7e8b0-a9c9-4541-9ad0-d3eeb445fdb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3