Using should and must_not in bool query

Hi,

I have a query that is very similar to the terms query, but with more
restriction. I would like to get
the documents that have specific terms appear in the query.

for example:

  1. {"doc":{"title":"looking dasd abd"}}
  2. {"doc":{"title":"afas abd"}}
  3. {"doc":{"title":"afas"}}
  4. {"doc":{"title":"looking dasd"}}
  5. {"doc":{"title":"looking dasd ghi"}}

how can i get result like doc 3 and 4 using should and must_not query...

how can i write a query that does this?

thanks in advance..

Regards,
Sumit Gupta

hi all for getting the result i make a query like..

curl -XGET 'http://localhost:9200/tweet2/type2/_search' -d '
{
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"field": {
"Title": "((looking AND dasd) OR afas)"
}
}
],
"must_not": [
{
"field": {
"Title": "abd OR ghi"
}
}
],
"minimum_number_should_match": 1
}
},
"filter": {
"range": {
"CreatedAt": {
"lt": "2011-11-15T00:00:00"
}
}
}
}
}
}'

but it is not giving any result but query is executed..please help me how i can implement bool query using should and must_not...

please help me

Regards
Sumit Gupta

The field names are case-sensitive. Try using "title" instead of "Title".

On Monday, April 30, 2012 1:34:12 AM UTC-4, Sumit Gupta wrote:

hi all for getting the result i make a query like..

curl -XGET 'http://localhost:9200/tweet2/type2/_search' -d '
{
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"field": {
"Title": "((looking AND dasd) OR
afas)"
}
}
],
"must_not": [
{
"field": {
"Title": "abd OR ghi"
}
}
],
"minimum_number_should_match": 1
}
},
"filter": {
"range": {
"CreatedAt": {
"lt": "2011-11-15T00:00:00"
}
}
}
}
}
}'

but it is not giving any result but query is executed..please help me how
i
can implement bool query using should and must_not...

please help me

Regards
Sumit Gupta

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/using-should-and-must-not-in-bool-query-tp3943532p3950015.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

thanx Igor Motov..

thats the reason.

Regards,
Sumit Gupta