until now i had to identify a datastructure by a single sef-url. In my json doc i had:
"sefUrl" : "cat-13"
I had to set sefUrl as not_analyzed. To identify this datastructure with an exact match, i used following code:
final String sefUrl = "cat-13";
final SearchResponse response = getClient().prepareSearch(INDEX)
.setTypes(TYPE).setSearchType(SearchType.QUERY_THEN_FETCH)
.setQuery(QueryBuilders.termQuery("sefUrl", sefUrl))
.execute()
.actionGet();
That worked fine until i now have the requirement for a multilanguage support on the sefUrl which i realized with a HashMap. In my json doc now i have:
"sefUrlMap" : {
"en" : "encat-13",
"de" : "cat-13"
}
How can i now do an exact match on this map to identify this datastructure?
on i've kicked the nested type from my mapping and replaced it with the object type and use my termquery from before and access the inner field with the dot notation and it works
this i can read 100 times, i can not understand when to use object and when to use nested
Nested objects are typically used, when there is an array of such objects and you need to preserve relationship between fields within an object. Like in case of make and model in the example from the guide. If you have only one instance of an object, there is no relationship and therefore there is no need to use nested.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.