elasticsearchelasticsearch-dslelasticsearch-dsl-py

Elasticsearch document -- what does the "input" key do?


I am working in a legacy codebase, and I have documents that are being indexed in ElasticSearch that look like the below image. I am trying to determine what feature or functional part of ElasticSearch is being used in the image below, with these "input" keys.

example ES document

The reason I need to know is because I have reason to suspect that this feature or whatever it is, is not supported by OpenSearch, due to bugs cropping up around these fields in particular (I recently upgraded). However, I can perform a search that successfully queries for these fields when using my current version of ElasticSearch, doing something like the below. However, the same code does not work in an updated version of OpenSearch:

from elasticsearch import Elasticsearch, RequestsHttpConnection

ELASTICSEARCH_URL = "localhost:9200/"
ES_CLIENT = Elasticsearch(
    [ELASTICSEARCH_URL], 
    connection_class=RequestsHttpConnection
)
q = "Brian Peterson"
queries = (MatchPhrasePrefix(full_name=q))
s = (
    Search(using=client, index="riders")
    .query(queries)
    .highlight_options(order="score")
    .extra(from_=0, size=25)
)

hits = s.execute().hits
result = hits.hits[0]

I can't find any reference to input, used this way, in old or new documentation, release notes or anything. Does anyone know what this "input" key is supposed to do? Any guesses? Is it just an old bug, maybe? I need to know definitively in order to be comfortable removing it.

It looks a bit like this feature, related to "watchers", but the format is different: https://www.elastic.co/guide/en/elasticsearch/reference/6.3/input-simple.html.
I also find references to LogStash plugins when I search for "Elasticsearch DSL input" or similar things.

The version we were using of ElasticsSearch was possibly version 6.3.2.


Solution

  • It's usually used in completion fields for building completion suggesters.

    Your MatchPhrasePrefix query should not return anything as completion fields work differently as explained in the link I shared above. You should get the following error:

    failed to create query: Can only use phrase prefix queries on text fields - not on [full_name] which is of type [completion]

    As far as I know, Opensearch also supports suggesters.