Search query based on the document's different field value's comparison

Hi Shay,
Can you please guide me to the following problem, suppose i am
having the following document structure,

{
"name":"narinder",
"guid" : "345435",
"parent_guid": "544333",
"country_guid": "456778",
"current_location_guid":"765432"
}

Here I want to search all the document, where country_guid ==
current_location_guid, and same kind of search on string fields too. Is it
implemented in elasticsearch??

and more over I need to add the higher priority on such case too using
custom_filter_score query, if its possible in elasticsearch, please help me
in the syntax too,

Thank you
Narinder Kaur

On Tuesday, 10 July 2012 12:57:11 UTC+5:30, Narinder Kaur wrote:

Hi Shay,
Can you please guide me to the following problem, suppose i am
having the following document structure,

{
"name":"narinder",
"guid" : "345435",
"parent_guid": "544333",
"country_guid": "456778",
"current_location_guid":"765432"
}

Here I want to search all the document, where country_guid ==
current_location_guid, and same kind of search on string fields too. Is it
implemented in elasticsearch??

Hello

Perhaps you could do something like the following?

"filtered" : {
"query" : {
...
},
"filter" : {
"script" : {
"script" : "doc['country_guid'].value == doc['current_location_guid'].value"
}
}
}

HTH.

  • shaun

--
shaun etherton
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Tuesday, 10 July 2012 at 4:57 PM, Narinder Kaur wrote:

Hi Shay,
Can you please guide me to the following problem, suppose i am having the following document structure,

{
"name":"narinder",
"guid" : "345435",
"parent_guid": "544333",
"country_guid": "456778",
"current_location_guid":"765432"
}

Here I want to search all the document, where country_guid == current_location_guid, and same kind of search on string fields too. Is it implemented in elasticsearch??

thank you, it will be really helpful.

On Tuesday, 10 July 2012 18:21:34 UTC+5:30, Shaun Etherton wrote:

Hello

Perhaps you could do something like the following?

"filtered" : {
"query" : {
...
},
"filter" : {
"script" : {
"script" : "doc['country_guid'].value ==
doc['current_location_guid'].value"
}
}
}

Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH.

  • shaun

--
shaun etherton
Sent with Sparrow http://www.sparrowmailapp.com/?sig

On Tuesday, 10 July 2012 at 4:57 PM, Narinder Kaur wrote:

Hi Shay,
Can you please guide me to the following problem, suppose i am
having the following document structure,

{
"name":"narinder",
"guid" : "345435",
"parent_guid": "544333",
"country_guid": "456778",
"current_location_guid":"765432"
}

Here I want to search all the document, where country_guid ==
current_location_guid, and same kind of search on string fields too. Is it
implemented in elasticsearch??