1

For example this document

{
   _index: "documents",
   _type: "_doc",
   _id: "bjQbFXMBUTNnZQiIspyw",
   _score: 1,
   _source: {
      text: "blablabla",
      tags: [
       "apple",
       "iphone",
       "iphonexr"
      ]
}

When i enter "iphon", i want to get "iphone", "iphonexr":

 suggest:  {
    gotsuggest:  {
      prefix : "iphon",
      completion : {
        field : "tags"
      }
    }
  }

A result, in field text there is only "iphone" tag. So, how i can get "iphone" and "iphonexr"?

{
    text: "iphone",
   _index: "documents",
   _type: "_doc",
   _id: "bjQbFXMBUTNnZQiIspyw",
   _score: 1,
   _source: {
      text: "blablabla",
      tags: [
       "apple",
       "iphone",
       "iphonexr"
      ]
}
パシャ
  • 11
  • 1

1 Answers1

0

Hi Welcome to StackOverflow community.

You have two ways of doing it

1.Use ingest pipeline, which will add apple, iphonexr to you tags field if it has iPhone in its value itself at time of indexing documents

Here is a way to do it.

Basically Elasticsearch cluster has an ingest node and its work is to change document fields value based on some conditions that you tell it.

Each condition is known as a processor. While indexing your documents you tell elasticsearch what processors to use.

Here is what ingest pipeline is : https://www.elastic.co/guide/en/elasticsearch/reference/master/ingest.html

Here is how you create append processor : https://www.elastic.co/guide/en/elasticsearch/reference/master/append-processor.html

2. use scripting to fill values in array on runtime with apple, iphonexr if it has value as iphone.

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-fields.html

gaurav9620
  • 1,147
  • 12
  • 30