New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot aggregate on completion suggester field in elasticsearch #5930
Comments
well I don't think it shoudl throw a NPE but on the other hand why whould you want to aggregate on a suggest field. you should use multi field for this IMO. @jpountz can you take a look at this NPE and provide a better error message? |
If I understand correctly, currently the completion suggester creates a field (called "domain") in the above example which contains the content of "input" and is searchable but one cannot aggregate, because of the special format of this type ( @jpountz please correct if I am wrong). A better error message would be useful.
It is unclear to me how
I would have expected
and then expected that aggregation would work on "domain.input". Is that supposed to work so so? If so, I think it is broken. In any case, it might be nice to have an option to make all parameter fields searchable and and also allow aggregations on them. Currently, the only way to do this seems to be to add the parameters to a field with a different name than the suggestion field. Instead, suggester could create these fields automatically if the user wants to. We could have something like:
which would cause creation of fields Does that make sense? |
I tried multi_fiield and it works as what I wanted. {
"domain": {
"type": "multi_field",
"fields": {
"domain": {
"max_input_length": 50,
"preserve_separators": true,
"payloads": false,
"analyzer": "simple",
"preserve_position_increments": true,
"type": "completion"
},
"input": {
"type": "string"
}
}
}
} Thank you for the hint @s1monw . |
@brwe I just tried a multi-field setup, and this seems to work fine: DELETE /test
PUT /test
{
"mappings": {
"test": {
"properties": {
"my_field": {
"type": "completion",
"analyzer": "simple",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
PUT /test/test/1
{
"my_field": "foo bar"
}
PUT /test/test/2
{
"my_field": "foo bar baz"
}
POST /test/_refresh
GET /test/_suggest
{
"my-suggest" : {
"text" : "foo b",
"completion" : {
"field" : "my_field"
}
}
}
GET /test/_search
{
"aggs": {
"my_field_values": {
"terms": {
"field": "my_field.raw"
}
}
}
} Adding capabilities to store |
Ah! Now I get it. I was trying out how this works when you explicitly provide "input" and "output" when indexing. I guess this is meant by "opt in for the shortest form".
Ok, I'l just add the more descriptive error message. |
@brwe can you port this to |
done |
In the mapping, the field named domain (String value) is a completion suggester as below:
Currently, I would like to aggregate based on the value in the field "domain". The example of a query in Sense is shown below.
localhost:9200
When the query is run, it returns NullPointerException. The detailed response is following.
Does the type of the suggester matter? How can it work to aggregate by the values of domain field?
The text was updated successfully, but these errors were encountered: