Hi,
Very new to elasticsearch, but also very impressed (coming from using
FAST ESP). One question that I've come up to, is that I'm trying to
determine if it's possible to use a has_child (either filter or query)
in a facet?
Hi,
Very new to elasticsearch, but also very impressed (coming from using
FAST ESP). One question that I've come up to, is that I'm trying to
determine if it's possible to use a has_child (either filter or query)
in a facet?
It should be possible, never tested it though (use has_child filter as a facet filter). Note that has_child filter can be expensive, so it might make more sense to redesign the doc structure.
On Friday, February 25, 2011 at 4:35 AM, Matt Paul wrote:
Hi,
Very new to elasticsearch, but also very impressed (coming from using
FAST ESP). One question that I've come up to, is that I'm trying to
determine if it's possible to use a has_child (either filter or query)
in a facet?
Thanks for the quick reply! The child structure contains often updated
fields (and the parent can potentially have large text blocks,
sometimes multi-meg), so I figured that putting the those fields that
change in a child document would keep the majority of the data from
having to be reindexed on updates (like I said, I'm new, but I thought
that was the basic intent of parent/child?). Anyway, here's what I'm
trying to do, and the error I'm getting (matchall on the query part
only for the example):
curl -XPOST "http://localhost:9200/1861_active/_search?pretty=true" -
d
'{"query" : {
"matchAll" : {}},
"facets" : {
"results" : {
"filter" : {
"has_child" : {
"type" : "results",
"query" : {
"term" : {"rsvb" : "1"}
}
}
}
}
}
}'
here's the error:
{
"error" : "SearchPhaseExecutionException[Failed to execute phase
[query], total failure; shardFailures {[a0-heKheQqytwK2yhJD3tQ]
[1861_30c77ae1ebe541dbbab4740121d1c76a][0]:
QueryPhaseExecutionException[[1861_30c77ae1ebe541dbbab4740121d1c76a]
[0]: query[ConstantScore(:)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: }{[a0-heKheQqytwK2yhJD3tQ]
[1861_30c77ae1ebe541dbbab4740121d1c76a][1]:
QueryPhaseExecutionException[[1861_30c77ae1ebe541dbbab4740121d1c76a]
[1]: query[ConstantScore(:)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: }{[a0-heKheQqytwK2yhJD3tQ]
[1861_30c77ae1ebe541dbbab4740121d1c76a][2]:
QueryPhaseExecutionException[[1861_30c77ae1ebe541dbbab4740121d1c76a]
[2]: query[ConstantScore(:)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: }{[a0-heKheQqytwK2yhJD3tQ]
[1861_30c77ae1ebe541dbbab4740121d1c76a][3]:
QueryPhaseExecutionException[[1861_30c77ae1ebe541dbbab4740121d1c76a]
[3]: query[ConstantScore(:)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: }{[a0-heKheQqytwK2yhJD3tQ]
[1861_30c77ae1ebe541dbbab4740121d1c76a][4]:
QueryPhaseExecutionException[[1861_30c77ae1ebe541dbbab4740121d1c76a]
[4]: query[ConstantScore(:)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: }]",
"status" : 500
and here's what's in the child (results):
curl -XPOST "http://localhost:9200/1861_active/results/_search?
pretty=true" -d '{"query" : { "matchAll" : {}}}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "1861_30c77ae1ebe541dbbab4740121d1c76a",
"_type" : "results",
"_id" : "8231e9f27b0c46bcb3a51144a260dd80:81",
"_score" : 1.0, "_source" : { "rsvb" : 81, "rsvt" :
1298513264000, "_id" : "8231e9f27b0c46bcb3a51144a260dd80:81",
"_parent" : "8231e9f27b0c46bcb3a51144a260dd80:81" }
}, {
"_index" : "1861_30c77ae1ebe541dbbab4740121d1c76a",
"_type" : "results",
"_id" : "638004ea46d6454b947bff9d6878c342:81",
"_score" : 1.0, "_source" : { "rsvb" : 81, "rsvt" :
1298573507000, "_id" : "638004ea46d6454b947bff9d6878c342:81",
"_parent" : "638004ea46d6454b947bff9d6878c342:81" }
} ]
}
Not quite sure what I'm doing wrong?
Probably should also include, here's what an insert on the child table
looks like (using bulk inserts):
{ "index" : { "_index" : "1861_active", "_type" : "results", "_id" :
"8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" :
"8a08dfb3af854f07b72b04b977f27f2a:81" } }
{ "rsvb" : 81, "rsvt" : 1298602356000, "_id" :
"8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" :
"8a08dfb3af854f07b72b04b977f27f2a:81" }
Additionally, here's the insert on the child (bulk insert):
{ "index" : { "_index" : "1861_active", "_type" : "results", "_id" :
"8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" :
"8a08dfb3af854f07b72b04b977f27f2a:81" } }
{ "rsvb" : 81, "rsvt" : 1298602356000, "_id" :
"8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" :
"8a08dfb3af854f07b72b04b977f27f2a:81" }
Can you create a recreation based on Elasticsearch Platform — Find real-time answers at scale | Elastic?
On Friday, February 25, 2011 at 4:56 AM, Matt Paul wrote:
Additionally, here's the insert on the child (bulk insert):
{ "index" : { "_index" : "1861_active", "_type" : "results", "_id" :
"8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" :
"8a08dfb3af854f07b72b04b977f27f2a:81" } }
{ "rsvb" : 81, "rsvt" : 1298602356000, "_id" :
"8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" :
"8a08dfb3af854f07b72b04b977f27f2a:81" }
Shay,
Here you go. While creating this example, I think I found that the culprit
has something to do with the alias I'm creating for the index (it doesn't
error out if I don't use aliasing at all):
curl -XPUT "http://localhost:9200/err_test_real" -d '{ "mappings" :
{ "results" : { "_parent" : { "type" : "doc" }}}}'
curl
-XPUT "http://localhost:9200/err_test_real/doc/8a08dfb3af854f07b72b04b977f27f2a:81"
-d '{ "col" : "some_data", "_id" : "8a08dfb3af854f07b72b04b977f27f2a:81" }'
curl -XPOST "http://localhost:9200/_aliases" -d '{"add" :
{"index" : "err_test_real", "alias" : "err_test"}}'
curl
-XPUT "http://localhost:9200/err_test/results/8a08dfb3af854f07b72b04b977f27f2a:81?parent=8a08dfb3af854f07b72b04b977f27f2a:81"
-d'{ "child_column" :
42, "_id" : "8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" : "8a08dfb3af854f07b72b04b977f27f2a:81"
}'
curl -XPOST "http://localhost:9200/err_test/_refresh"
curl -XPOST "http://localhost:9200/err_test/doc/_search?pretty=true"
-d '{"query" : { "matchAll" : {}}},
"facets" : {
"results" : {
"filter" : {
"has_child" : {
"type" : "results",
"query" : {
"term" : {"child_column" : 42}
}
}
}
}
}'
Please gist it.
On Friday, February 25, 2011 at 11:56 PM, purplegherkin@gmail.com wrote:
Shay,
Here you go. While creating this example, I think I found that the culprit has something to do with the alias I'm creating for the index (it doesn't error out if I don't use aliasing at all):
curl -XPUT "http://localhost:9200/err_test_real" -d '{ "mappings" : { "results" : { "_parent" : { "type" : "doc" }}}}'
curl -XPUT "http://localhost:9200/err_test_real/doc/8a08dfb3af854f07b72b04b977f27f2a:81" -d '{ "col" : "some_data", "_id" : "8a08dfb3af854f07b72b04b977f27f2a:81" }'
curl -XPOST "http://localhost:9200/_aliases" -d '{"add" : {"index" : "err_test_real", "alias" : "err_test"}}'
curl -XPUT "http://localhost:9200/err_test/results/8a08dfb3af854f07b72b04b977f27f2a:81?parent=8a08dfb3af854f07b72b04b977f27f2a:81" -d'{ "child_column" : 42, "_id" : "8a08dfb3af854f07b72b04b977f27f2a:81", "_parent" : "8a08dfb3af854f07b72b04b977f27f2a:81" }'
curl -XPOST "http://localhost:9200/err_test/_refresh"
curl -XPOST "http://localhost:9200/err_test/doc/_search?pretty=true" -d '{"query" : { "matchAll" : {}}},
"facets" : {
"results" : {
"filter" : {
"has_child" : {
"type" : "results",
"query" : {
"term" : {"child_column" : 42}
}
}
}
}
}'
Shay,
Here ya go: git://gist.github.com/847657.git
thanks for taking a look!
Matt
Sorry, that should have read: facet has_child error example · GitHub
On Feb 28, 2011 11:23am, purplegherkin@gmail.com wrote:
Shay,
Here ya go: git://gist.github.com/847657.git
thanks for taking a look!
Matt
Heya,
Several problems with the search request (the json is malformed). But, in any case, this did not work properly. Here is a gist of an example of how it should work: gist:848506 · GitHub, and support for that has been pushed to master (Search: Allow to use has_child filter in facets · Issue #730 · elastic/elasticsearch · GitHub).
-shay.banon
On Monday, February 28, 2011 at 11:28 PM, purplegherkin@gmail.com wrote:
Sorry, that should have read: facet has_child error example · GitHub
On Feb 28, 2011 11:23am, purplegherkin@gmail.com wrote:
Shay,
Here ya go: git://gist.github.com/847657.git
thanks for taking a look!
Matt
Thanks Shay, I'll download the update and give it a try!
On Feb 28, 2011 8:49pm, Shay Banon shay.banon@elasticsearch.com wrote:
Heya,
Several problems with the search request (the json is malformed). But, in
any case, this did not work properly. Here is a gist of an example of how
it should work: gist:848506 · GitHub, and support for that has
been pushed to master
(Search: Allow to use has_child filter in facets · Issue #730 · elastic/elasticsearch · GitHub).
-shay.banon
On Monday, February 28, 2011 at 11:28 PM, purplegherkin@gmail.com wrote:
Sorry, that should have read: facet has_child error example · GitHub
On Feb 28, 2011 11:23am, purplegherkin@gmail.com wrote:
Shay,
Here ya go: git://gist.github.com/847657.git
thanks for taking a look!
Matt
Shay,
I just tested it all, works like a champ now, thanks!
Matt
© 2020. All Rights Reserved - Elasticsearch
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.