# Filter and tokenizer not working

**URL:** <https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043>\
**Category:** Elasticsearch\
**Created:** [July 8, 2018, 9:57am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043 "2018-07-08T09:57:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_Lotfy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lotfy/32/33112_2.png) [@Mohamed\_Lotfy](https://discuss.elastic.co/u/Mohamed_Lotfy)\
**Post date:** [July 8, 2018, 9:57am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/1 "2018-07-08T09:57:26Z")

</div>

Hello dudes  
recently I work for a task to use Elasticsearch with node.js and mongoose  
then I used [Mongoosastic](https://github.com/mongoosastic/mongoosastic) to be easier to link them together so  
I create a schema and add an analyzer called " **edge\_nGram\_analyzer**" as shown below

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/f/7f2a861f5dbd73960bc3413069c06b4c8ff5f5d9.png)

then add settings to my analyzer as shown below

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/f/dfbac1ee339b6ea8e6a1b3d89da4ac0ef87ce7ae.png)

**My problem** that Elasticsearch work **but filter and tokenizer** not working and I don't know why can't work

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 8, 2018, 9:59am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/2 "2018-07-08T09:59:15Z")

</div>

Please don't post pictures of text, they are difficult to read and may not show for some people.

Also, we're not all dudes 🙂

---

<div class="post-metadata">

**Author:** ![Mohamed\_Lotfy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lotfy/32/33112_2.png) [@Mohamed\_Lotfy](https://discuss.elastic.co/u/Mohamed_Lotfy)\
**Post date:** [July 8, 2018, 10:02am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/3 "2018-07-08T10:02:42Z")

</div>

sorry for dudes and pictures @warkolm

```
var mongoose = require("mongoose");
    var mongoosastic = require("mongoosastic");
    mongoose.Promise = global.Promise;

var connectionString = "mongodb://127.0.0.1:27017/elastic_test";
mongoose.connect(connectionString);

var bookSchema = new mongoose.Schema({
  author: { type: String, es_type: "text", es_indexed: true },
  title: { type: String, es_type: "text", es_indexed: true },
  description: { type: String, es_type: "text", es_indexed: true },
  creation: { type: String, es_type: "text", es_indexed: false },
  content: {
type: String,
es_type: "text",
es_indexed: true,
analyzer: "edge_nGram_analyzer"
  }
});

bookSchema.plugin(mongoosastic, {
  hosts: ["localhost:9200", "anotherhost:9200"]
});

var Book = mongoose.model("Books-Collection", bookSchema);

Book.createMapping(
  {
settings: {
  analysis: {
    analyzer: {
      edge_nGram_analyzer: {
        type: "custom",
        tokenizer: "edge_ngram_tokenizer",
        filter: ["lowercase", "edgeNGram_filter"]
      }
    },
    filter: {
      edgeNGram_filter: {
        type: "edge_ngram",
        min_gram: 3,
        max_gram: 20
      }
    },
    tokenizer: {
      edge_ngram_tokenizer: {
        type: "edge_ngram",
        min_gram: 3,
        max_gram: 50,
        token_chars: ["letter"]
      }
    },
    mappings: {
      _doc: {
        properties: {
          title: {
            type: "text",
            analyzer: "edge_nGram_analyzer",
            search_analyzer: "edge_nGram_analyzer"
          }
        }
      }
    }
  }
}
  },
  function(err, mapping) {
if (err) throw err;
else console.log("Mapping created", " go for http://localhost:3000/");
  }
);
```

---

<div class="post-metadata">

**Author:** ![Mohamed\_Lotfy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lotfy/32/33112_2.png) [@Mohamed\_Lotfy](https://discuss.elastic.co/u/Mohamed_Lotfy)\
**Post date:** [July 8, 2018, 10:15am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/4 "2018-07-08T10:15:21Z")

</div>

@warkolm @dadoonet @Christian_Dahlqvist can you help here

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 8, 2018, 10:58am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/5 "2018-07-08T10:58:58Z")

</div>

This forum is manned by volunteers, so please be patient. If you have not received any response within a few days (excluding weekends) it is generally fine to bump the thread. Please also avoid pinging people not already involved in the thread.

---

<div class="post-metadata">

**Author:** ![Mohamed\_Lotfy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lotfy/32/33112_2.png) [@Mohamed\_Lotfy](https://discuss.elastic.co/u/Mohamed_Lotfy)\
**Post date:** [July 8, 2018, 11:07am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/6 "2018-07-08T11:07:01Z")

</div>

okay @Christian_Dahlqvist but why volunteers work for some people and not another people  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/4/74e8e497957754492b9ac6761c577fd52760437b.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 8, 2018, 11:26am UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/7 "2018-07-08T11:26:24Z")

</div>

Being a volunteer means I have no obligation to help anyone. I choose when I want to contribute and which issues I want to help with.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 8, 2018, 6:48pm UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/9 "2018-07-08T18:48:26Z")

</div>

I am not sure how many people that have experience with `mongoosastic`, but I do not. It would therefore help if you could show the resulting mappings using the [get mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/indices-get-mapping.html) together with a few sample documents. If you can show in detail exactly what is not working, e.g. by showing a query and the corresponding response, that would help too.

---

<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:** [August 5, 2018, 6:48pm UTC](https://discuss.elastic.co/t/filter-and-tokenizer-not-working/139043/10 "2018-08-05T18:48:27Z")

</div>

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