Sample data in an index is shown below –
[
{
PID =”PID1”,
…
CHILDREN =
[
{
CID=”CID1”
…
FLAG = false
},
{
CID=”CID2”
…
FLAG = true
},
…
]
},
{
PID =”PID2”,
…
CHILDREN =
[
{
CID=”CID1”
…
FLAG = true
},
{
CID=”CID2”
…
FLAG = false
},
…
]
},
…
]
RULE: Each specific CID object will have FLAG = true in one and only one
PID object; in other PID objects, FLAG = false may exist.
*QUERY: * Find PID object for which CID= and FLAG
corresponding to CID object is set to true. For example, it shall be PID2
object if CID1 is searched and it shall be PID1 obejct If CID2 is searched. What
is the best solution to solve it?
NOT A SOLUTION
es_client.prepareSearch(<index_name>)
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setQuery(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("CHILDREN.CID ",
“CID1”))
.must(QueryBuilders.termQuery("CHILDREN .FLAG",
true)))
)
ONE SOLUTION
If we use only QueryBuilders.termQuery("CHILDREN.CID ", “CiD1”)) in
setQuery, it returns all PID objects having CID = “CID1”. Parse the result
and check which PID object is actually having CID1 object where FLAG=true. Any
better solution than this?
--
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/582d2e01-50bb-45b8-8dfa-7ea6b28ece53%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.