Hi,
Is it possible to do a suggestion completion on a type. im able to do it on
an index .
POST /data/_suggest
{
"data" : {
"text" : "tr",
"completion" : {
"field" : "sattributes",
"size":50
}
}
}
when i do on a type
POST /data/suggestion/_suggest
{
"data" : {
"text" : "tr",
"completion" : {
"field" : "sattributes",
"size":50
}
}
}
"suggestion" is the type
i don't get any results. I need to do suggestion on two different types
articles and books. Do i need to create separate indexes to make them work
or is there a way in elasticsearch to accomplish this. In case if i have to
search on my index "data" is there way to get 50 results for type "article"
and 50 results for type "book".
Any help is highly appreciated.
--
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/9b68f9f2-e566-414c-908c-4403ce0a2bcb%40googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
spinscale
(Alexander Reelsen)
February 6, 2014, 10:19am
2
Hey,
right now the completion suggester only works per index, but not per type.
There is some work going on to add a context around a suggester, which
would allow for cases like that, see
elastic:master
← chilling:ContextSuggester
opened 02:31PM - 01 Nov 13 UTC
This commit extends the `CompletionSuggester` by context
informations. In exampl… e such a context informations can
be a simple string representing a category reducing the
suggestions in order to this category.
Three base implementations of these context informations
have been setup in this commit.
- a Category Context
- a Geo Context
- a Field Context
All the mapping for these context informations are
specified within a context field in the completion
field that should use this kind of information.
## Mapping Example
The following example shows the mapping for a GeoContext.
```
{
"testType":{
"properties":{
"testField":{
"type":"completion",
"index_analyzer":"simple",
"search_analyzer":"simple",
"payloads":true,
"preserve_separators":false,
"preserve_position_increments":true,
"context":{
"geo":{
"separator":"|",
"precision":8,
"neighbors":true
}
}
}
}
}
}
```
## Indexing
During indexing a document the subfield `context` of the
completion field contains the data to be used in order
to provide suggestions.
```
{
"testField":{
"input":[["pizza - berlin","pizza","food"]],
"context":"u33dc1v0xupz"
}
}
```
## Suggestion Example
The Suggestion request is extended by a context value. The
suggest request for a geolocation looks like
```
{
"suggest":{
"text":"pizza",
"completion":{
"field":"testField",
"size":10,
"context":{
"geo":"u33dc0cpke4q"
}
}
}
}
```
The context objects contains a field with the same name as
defined in the mapping. According to the type of the context
this field contains the data associated with the suggestion
request. In this example the geohash of a location.
## Category Context
The simplest way to use this feature is a category context. It
supports a arbitrary name of a category to use with the completion
suggest API.
To set the context support to the category type this option must be
set to `true`:
```
"testField":{
"type":"completion",
"context":{
"category": true
}
}
```
The name of the context category then needs to be set within the
suggestion context during indexing:
```
{
"testField":{
"input":[["pizza - berlin","pizza","food"]],
"context":"delivery"
}
}
```
and can be used by setting the category value:
```
{
"suggest":{
"text":"pizza",
"completion":{
"field":"testField",
"size":10,
"context":{
"category":"delivery"
}
}
}
}
```
## Field Context
The Field Context works like the category context but the value of this
will context will not explicitly be set. It refers to another field in
the document. In example a `category` field.
```
{
"category":{
"type": "string"
},
"testField":{
"type":"completion",
"context":{
"field": "category"
}
}
}
```
for indexing the field context must be set to true:
```
{
"category":"delivery",
"testField":{
"input":[["pizza - berlin","pizza","food"]],
"context":true
}
}
```
and suggestions use the `context.field` value
```
{
"suggest":{
"text":"pizza",
"completion":{
"field":"testField",
"size":10,
"context": {
"field": "delivery"
}
}
}
}
```
## Geo Context
The last context feature is the GeoContext. It take a location into account.
For example if one searches for delivery services it might be use full to find
results around the location the query was sent. This context internally works
on geohashes only but the REST API allows any form defined for `geo_points`
In the mapping this kind of context is configured by two parameters:
- precision
- neighbors
The `precision` option is used to configure the range of result. If the
`neighbors` option is enabled not only the given geohash cell will be used
but also all it's neighbors.
```
"context":{
"geo":{
"separator":"|",
"precision":8,
"neighbors":true
}
}
```
The context during indexing is set to the location of the input:
```
{
"testField":{
"input":[["pizza - berlin","pizza","food"]],
"context": "u33dc1v0xupz"
}
}
```
To get a ist of suggestions around a specific area the `context.geo` field
must contain the position of this area:
```
{
"suggest":{
"text":"pizza",
"completion":{
"field":"testField",
"size":10,
"context": {
"geo": "u33dc0cpke4q"
}
}
}
}
```
Closes #3959
hope this helps.
--Alex
On Tue, Feb 4, 2014 at 11:11 PM, Avinash Mohan avilanchee@gmail.com wrote:
Hi,
Is it possible to do a suggestion completion on a type. im able to do it
on an index .
POST /data/_suggest
{
"data" : {
"text" : "tr",
"completion" : {
"field" : "sattributes",
"size":50
}
}
}
when i do on a type
POST /data/suggestion/_suggest
{
"data" : {
"text" : "tr",
"completion" : {
"field" : "sattributes",
"size":50
}
}
}
"suggestion" is the type
i don't get any results. I need to do suggestion on two different types
articles and books. Do i need to create separate indexes to make them work
or is there a way in elasticsearch to accomplish this. In case if i have to
search on my index "data" is there way to get 50 results for type "article"
and 50 results for type "book".
Any help is highly appreciated.
--
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/9b68f9f2-e566-414c-908c-4403ce0a2bcb%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out .
--
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-rvbBoB7srYBbP9ktp0We2tSu36%2BA%2BmwtCDv_9z4fyEA%40mail.gmail.com .
For more options, visit https://groups.google.com/groups/opt_out .