Filter and tokenizer not working


(Mohamed Lotfy) #1

Hello dudes
recently I work for a task to use Elasticsearch with node.js and mongoose
then I used Mongoosastic to be easier to link them together so
I create a schema and add an analyzer called "edge_nGram_analyzer" as shown below

then add settings to my analyzer as shown below

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


(Mark Walkom) #2

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 :slight_smile:


(Mohamed Lotfy) #3

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/");
  }
);

(Mohamed Lotfy) #4

@warkolm @dadoonet @Christian_Dahlqvist can you help here


(Christian Dahlqvist) #5

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.


(Mohamed Lotfy) #6

okay @Christian_Dahlqvist but why volunteers work for some people and not another people
image


(Christian Dahlqvist) #7

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.


(Christian Dahlqvist) #9

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


(system) #10

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