Similarly module code not working in Node.Js

I have some data and I have to apply similarity module on it in settings part. I did that in Node.Js

I sent data to Elasticsearch Kibana with Bulk API but similarity module is not working.
I need help like how to integrate those things in nodes.
I'm attaching the code. Please see and help...

const { Client } = require('@elastic/elasticsearch')
const client = new Client({
  node: 'http://localhost:9200'
})

async function run () {
  await client.indices.create({
    index: 'resources',
    body: {
        "settings": {
            "index": {
              "similarity": {
                "my_similarity": {
                  "type": "DFR",
                  "basic_model": "g",
                  "after_effect": "l",
                  "normalization": "h2",
                  "normalization.h2.c": "3.0"
                }
              }
            },
            "analysis": {
                "analyzer": {
                  "my_custom_analyzer": {
                    "type": "custom",
                    "char_filter": ["html_strip"],
                    "tokenizer": "standard",
                    "filter": [
                      "lowercase",
                      "stop",
                      "asciifolding"
                    ]
                  }
                }
              },
          },
      mappings: {
        properties: {
          id: { type: 'text' , similarity : "my_similarity"},
          title: { type: 'text' , similarity : "my_similarity"},
          shortDescription: { type: 'text',similarity : "my_similarity"  },
          description: { type: 'text',similarity : "my_similarity", analyzer:"my_custom_analyzer" }
        }
      }
    }
  }, { ignore: [400] })

can you help share a fully fledged example including error codes? Also a pure curl/kibana based reproduction might help a lot on javascript folks to take a look at this issue.

Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.