Gchang10
(Gchang10)
June 6, 2014, 6:41pm
1
I am observing an issue with field reference in context suggester. Consider
the following use case:
PUT /services/service/_mapping
{
"service": {
"properties": {
"name": {
"type" : "string"
},
"network_id": {
"type" : "long"
},
"suggest_field": {
"type": "completion",
"context": {
"network": {
"type": "category",
"path": "network_id"
}
}
}
}
}
}
PUT /services/service/1
{
"name": "knapsack",
"network_id": 1,
"suggest_field": {
"input": ["knacksack", "backpack", "daypack"]
}
}
POST services/_suggest?pretty'
{
"suggest" : {
"text" : "k",
"completion" : {
"field" : "suggest_field",
"size": 10,
"context": {
"network": 1
}
}
}
}
The suggest query does not return any option. However, if I change the
field type of network_id to 'string' (and not_analyzed), the suggest query
works. Explicitly indexing the network_id as the context in the
suggest_field works as well:
PUT /services/service/1
{
"name": "knapsack",
"network_id": 1,
"suggest_field": {
"input": ["knacksack", "backpack", "daypack"],
"context": {"network_id": 1}
}
}
Seems like a bug?
--
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/214f059d-e2e6-4a28-aaaf-7dc6c1e1bcad%40googlegroups.com .
For more options, visit https://groups.google.com/d/optout .
spinscale
(Alexander Reelsen)
June 16, 2014, 1:02pm
2
Hey,
the problem is, that the mapping of the context variable 'network_id' is
not a string. Thinking if we either should support this or reject it
directly and only support string fields in the suggester.
Added github issue
opened 01:02PM - 16 Jun 14 UTC
closed 02:57PM - 21 Nov 15 UTC
Hey,
the context suggester only works with strings in the mapping if you specif… y a field, see this example
```
DELETE /services
PUT /services
PUT /services/service/_mapping
{
"service": {
"properties": {
"network_id": {
"type" : "long"
},
"suggest_field": {
"type": "completion",
"context": {
"network": {
"type": "category",
"path": "network_id"
}
}
},
"suggest_field2": {
"type": "completion",
"context": {
"network": {
"type": "category"
}
}
}
}
}
}
PUT /services/service/1
{
"name": "knapsack",
"network_id": "1",
"suggest_field": {
"input": ["knacksack", "backpack", "daypack"]
},
"suggest_field2": {
"input": ["knacksack", "backpack", "daypack"],
"context" : {
"network" : "1"
}
}
}
POST services/_suggest?pretty'
{
"suggest" : {
"text" : "k",
"completion" : {
"field" : "suggest_field",
"size": 10,
"context": {
"network": "1"
}
}
},
"suggest2" : {
"text" : "k",
"completion" : {
"field" : "suggest_field2",
"size": 10,
"context": {
"network": "1"
}
}
}
}
```
Solution 1: Call `toString()` for everything
Solution 2: Reject contexts for anything else than strings
--Alex
On Fri, Jun 6, 2014 at 8:41 PM, Gilbert Chang gilbertchang10@gmail.com
wrote:
I am observing an issue with field reference in context suggester.
Consider the following use case:
PUT /services/service/_mapping
{
"service": {
"properties": {
"name": {
"type" : "string"
},
"network_id": {
"type" : "long"
},
"suggest_field": {
"type": "completion",
"context": {
"network": {
"type": "category",
"path": "network_id"
}
}
}
}
}
}
PUT /services/service/1
{
"name": "knapsack",
"network_id": 1,
"suggest_field": {
"input": ["knacksack", "backpack", "daypack"]
}
}
POST services/_suggest?pretty'
{
"suggest" : {
"text" : "k",
"completion" : {
"field" : "suggest_field",
"size": 10,
"context": {
"network": 1
}
}
}
}
The suggest query does not return any option. However, if I change the
field type of network_id to 'string' (and not_analyzed), the suggest query
works. Explicitly indexing the network_id as the context in the
suggest_field works as well:
PUT /services/service/1
{
"name": "knapsack",
"network_id": 1,
"suggest_field": {
"input": ["knacksack", "backpack", "daypack"],
"context": {"network_id": 1}
}
}
Seems like a bug?
--
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/214f059d-e2e6-4a28-aaaf-7dc6c1e1bcad%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/214f059d-e2e6-4a28-aaaf-7dc6c1e1bcad%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout .
--
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/CAGCwEM-oAgFRo8sRkNCD2X4jo6ZUdevPHmyHS1nzd7JTeK0mgA%40mail.gmail.com .
For more options, visit https://groups.google.com/d/optout .