Skip to content

Deserialization of category context: wrong variant instance  #691

Open

Description

Elasticsearch Version

8.9.1

Installed Plugins

No response

Java Version

20.0.2

OS Version

5.15.0-83-generic elastic/elasticsearch#92-Ubuntu SMP Mon Aug 14 09:30:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Problem Description

Using Java client:

<dependency>
     <groupId>co.elastic.clients</groupId>
     <artifactId>elasticsearch-java</artifactId>
     <version>8.10.3</version>
 </dependency>

Index is created following this example: https://www.elastic.co/guide/en/elasticsearch/reference/8.10/search-suggesters.html#context-suggester

{
  "mappings": {
    "properties": {
      "suggest": {
        "type": "completion",
        "contexts": [
          {                                 
            "name": "place_type",
            "type": "category"
          }
        ]
      }
    }
  }
}

category context is deserialized as geo

Screen Shot 2023-10-16 at 8 55 33 PM

Steps to Reproduce

Step 1: mappings

PUT place
{
  "mappings": {
    "properties": {
      "suggest": {
        "type": "completion",
        "contexts": [
          {                                 
            "name": "place_type",
            "type": "category"
          }
        ]
      }
    }
  }
}

Step 2: index creation

PUT place/_doc/1
{
  "suggest": {
    "input": [ "timmy's", "starbucks", "dunkin donuts" ],
    "contexts": {
      "place_type": [ "cafe" ]                    
    }
  }
}

Step 3: query

{
  "_source": {
    "includes": [
      "_none_"
    ]
  },
  "suggest": {
    "suggest": {
      "completion": {
        "field": "suggest",
        "size": 10,
        "contexts": {
          "place_type": [
            {
              "context": "cafe"
            }
          ]
        },
        "skip_duplicates": true
      }
    },
    "text": "tim"
  }
}

I expected https://javadoc.io/static/co.elastic.clients/elasticsearch-java/8.0.0/co/elastic/clients/elasticsearch/core/search/Context.Kind.html#Category, however the instance is of Location type

Screen Shot 2023-10-16 at 8 55 33 PM

Logs (if relevant)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions