# Similarly module code not working in Node.Js

**URL:** <https://discuss.elastic.co/t/similarly-module-code-not-working-in-node-js/274114>\
**Category:** Elasticsearch\
**Created:** [May 26, 2021, 7:31pm UTC](https://discuss.elastic.co/t/similarly-module-code-not-working-in-node-js/274114 "2021-05-26T19:31:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![appydam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/appydam/32/89306_2.png) [@appydam](https://discuss.elastic.co/u/appydam)\
**Post date:** [May 26, 2021, 7:31pm UTC](https://discuss.elastic.co/t/similarly-module-code-not-working-in-node-js/274114/1 "2021-05-26T19:31:11Z")

</div>

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...

```auto
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] })

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 31, 2021, 7:55am UTC](https://discuss.elastic.co/t/similarly-module-code-not-working-in-node-js/274114/2 "2021-05-31T07:55:30Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 28, 2021, 7:55am UTC](https://discuss.elastic.co/t/similarly-module-code-not-working-in-node-js/274114/3 "2021-06-28T07:55:40Z")

</div>

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