elasticsearch


How to query for inner_hits against grandparents in multi-generational setup


So I've set up my Elasticsearch store according to this: https://www.elastic.co/guide/en/elasticsearch/guide/current/grandparents.html
PUT /company
{
"mappings": {
"country": {},
"branch": {
"_parent": {
"type": "country"
}
},
"employee": {
"_parent": {
"type": "branch"
}
}
}
}
POST /company/country/_bulk
{ "index": { "_id": "uk" }}
{ "name": "UK" }
{ "index": { "_id": "france" }}
{ "name": "France" }
POST /company/branch/_bulk
{ "index": { "_id": "london", "parent": "uk" }}
{ "name": "London Westmintster" }
{ "index": { "_id": "liverpool", "parent": "uk" }}
{ "name": "Liverpool Central" }
{ "index": { "_id": "paris", "parent": "france" }}
{ "name": "Champs Élysées" }
PUT /company/employee/1?parent=london&routing=uk
{
"name": "Alice Smith",
"dob": "1970-10-24",
"hobby": "hiking"
}
This query works fine and returns Alice as expected, but no inner_hits:
POST /company/employee/_search
{
"query": {
"has_parent": {
"type": "branch",
"query": {
"term": {"_id": "london"}
},
"inner_hits": {}
}
}
}
But this query doesn't return any inner_hits:
POST /company/employee/_search
{
"query": {
"has_parent": {
"type": "branch",
"query": {
"has_parent": {
"type": "country",
"query": {
"term": {"_id": "uk"}
}
},
"inner_hits": {}
}
}
}
}
I thought it would return Alice, but it doesn't. How do I find all employees whose country is uk?
Note that the example query on elastic.co doesn't return any inner_hits either. Here's the query:
GET /company/country/_search
{
"query": {
"has_child": {
"type": "branch",
"query": {
"has_child": {
"type": "employee",
"query": {
"match": {
"hobby": "hiking"
}
},
"inner_hits": {}
}
}
}
}
}
I got zero inner_hits.
This is currently an outstanding with inner_hits.
You can add on the issue here: https://github.com/elastic/elasticsearch/issues/11118

Related Links

How to calculate cooccurrences on a set of texts with Elasticsearch
elasticsearch edge_ngrams analyzer is not found
Double wildcard in query causes weird highlighting for plain/fast vectors elasticsearch highlighters
Get Elasticsearch response in DataTable in C#.Net
Elasticsearch NoNodeAvailableException issue
Why Elasticsearch snapshot stats number_of_files differs from actual indices count?
Specifying data type and analyzer while creating index
elasticsearch regroups aggs by regex
get unique values from elasticsearch
Elasticsearch dies on primary node at random times. What should I look for in troubleshooting?
elasticsearch problems with queries
Normalize elasticsearch query/results
ElasticSearch max shard size
Elasticsearch: Group results of different types in response structure
Storing data in Elasticsearch - OLTP
Elasticsearch + Shield, security_exception happens when Document Level Security is enabled

Categories

HOME
jboss
rust
mc
azure-functions
automapper
autocomplete
yql
web2py
tcp
google-webmaster-tools
sentry
mutation-testing
nexus3
lapack
stimulsoft
jodatime
asp.net-core-1.0
node-webkit
anova
kamailio
unrar
fstar
adapter
boolean-logic
dnsmasq
fusion
snap-framework
overwrite
osx-lion
custom-keyboard
markov-chains
android-canvas
runtimeexception
telephonymanager
uipickerview
get-event-store
system-on-chip
hdiv
flipkart
absolute
ssi
nonlinear-functions
popen
jsf-2.3
between
openseadragon
jeditable
persistent-object-store
management-studio-express
variable-length-array
srv-record
swagger-maven-plugin
alwayson
dbmigrate
wicked-gem
web-api
gflags
tidyr
ssmtp
pass-by-value
operands
sunos
fasterxml
dmake
oracle-adf-mobile
aho-corasick
git-reset
tabletools
oxygene
map
lync-2010
quickgraph
lru
mongo-jackson-mapper
proc-open
daap
sfinae
image-scanner
database-deadlocks
canonicalization
bass
android-2.1-eclair
resharper-5.0
ning
prism-2

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile