My Sample Data is shown below:

`{"listings":{"title" : "testing 1", "address" : { "line1" : "3rd cross", 
"line2" : "6th main", "line3" : "", "landmark" : "", "location" : "k r 
puram", "pincode" : "", "city" : "Bangalore" 
},"purpose":"rent","published": true, "inActive": false },
{"listings":{"title" : "testing 2", "address" : { "line1" : "3rd cross", 
"line2" : "6th main", "line3" : "", "landmark" : "", "location" : 
"banaswadi", "pincode" : "", "city" : "Bangalore" 
},"purpose":"sale","published": true, "inActive": false },
{"listings":{"title" : "testing 3", "address" : { "line1" : "3rd cross", 
"line2" : "6th main", "line3" : "", "landmark" : "", "location" : "tin 
factory", "pincode" : "", "city" : "Bangalore" 
},"purpose":"rent","published": true, "inActive": false }`

My index mapping is shown below:

    curl -X PUT localhost:9200/testing/listings/_mapping -d '{
     "listings" : {
        "properties" : {
            "address" : {
               "properties": {
                  "location": { "type" : "string",
                                "index" : "not_analyzed"
                   }
                }
            },
            "suggest" : { 
                 "type" : "completion", 
                 "index_analyzer" : "simple",
                 "search_analyzer" : "simple",
                 "payloads" : true
            }                              
        }                                  
      }
    }'

I access the listings object based on purpose property value like rent or 
sale.  I am able to access the objects for rent and sale individually.  How 
can i access listings object for both rent and sale values.  I have used 
below query to fetch both rent & sale listings object.

    {"query":{
       "filtered": {
         "filter": {
           "terms": {
             "purpose" : ["rent", "sale"]
            }
          }
        },
       "bool":{
         "must":[
           {"match":{"published":true}},
           {"match":{"inActive":false}},
           {"match":{"address.city": "bangalore"}}
          ]
       }
     }
    }

Please suggest the changes as needed. Thanks in advance.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/21ed4bf4-5fec-4d09-8c5c-5efca0ae125c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to