3

На самом деле я хочу удалить индексирование из некоторых полей, теперь кто-нибудь может рассказать мне, как я могу писать сопоставления для этого кода, которому выдается bel; ow может кто-нибудь сказать мне, что в этом плохого или может кто-нибудь скажет мне, как правильно это сделать.Как написать картографирование в mongoosastic в nodejs

Blog.createMapping(function(err, mapping){ 
    if(err){ 
     console.log('error creating mapping (you can safely ignore this)'); 
     console.log(err); 
    }else{ 
     mapping: { 
       properties: { 
        jeb_no: { 
         index: "no" 
        } 
       } 
     } 
     console.log('mapping created!'); 
     console.log(mapping); 
    } 

});

Заранее спасибо.

+0

вы нашли ответ? если да, то удалите этот вопрос? и если нет, то я дам вам ответ –

+0

@KevalBhatt: plz расскажите нам, как мы создаем сопоставление? Я все еще ищу этот ответ. –

+0

@DeepikaChalpe k see Я ответил –

ответ

4

пример: это пример для сохранения информации фильма

var mongoose = require('mongoose') 
Schema = mongoose.Schema, 
    mongoosastic = require("mongoosastic"), 
    var MovieSchema = new Schema({ 
     movieName: String, 
     movieYear: Number, 
     imageUrl: String, 
     genre: String, 
     director: String, 
     producer: String, 
     cast: String, 
     writer: String, 
     synopsis: String, 
     rating: Number, 
     price: Number, 
     rentPrice: Number, 
     format: String, 
     language: String, 
     offer: Number, 
     quantity: Number, 
     offerString: String, 
     createDate: Date, 
     updateDate: Date, 
    }); 

MovieSchema.plugin(mongoosastic); 
Movie = module.exports = mongoose.model('Movie', MovieSchema); 


Movie.createMapping({ 
    "settings": { 
     "number_of_shards": 1, 
     "number_of_replicas": 0, 
     "analysis": { 
      "filter": { 
       "nGram_filter": { 
        "type": "nGram", 
        "min_gram": 2, 
        "max_gram": 20, 
        "token_chars": [ 
         "letter", 
         "digit", 
         "punctuation", 
         "symbol" 
        ] 
       } 
      }, 
      "analyzer": { 
       "nGram_analyzer": { 
        "type": "custom", 
        "tokenizer": "whitespace", 
        "filter": [ 
         "lowercase", 
         "asciifolding", 
         "nGram_filter" 
        ] 
       }, 
       "whitespace_analyzer": { 
        "type": "custom", 
        "tokenizer": "whitespace", 
        "filter": [ 
         "lowercase", 
         "asciifolding" 
        ] 
       } 
      } 
     } 
    }, 
    "mappings": { 
     "movie": { 
      "_all": { 
       "analyzer": "nGram_analyzer", 
       "search_analyzer": "whitespace_analyzer" 
      }, 
      "properties": { 
       "movieName": { 
        "type": "string", 
       }, 
       "movieYear": { 
        "type": "double" 
       }, 
       "imageUrl": { 
        "type": "string" 
       }, 
       "genre": { 
        "type": "string" 
       }, 
       "director": { 
        "type": "string" 
       }, 
       "producer": { 
        "type": "string" 
       }, 
       "cast": { 
        "type": "String" 
       }, 
       "writer": { 
        "type": "string" 
       }, 
       "synopsis": { 
        "type": "string" 
       }, 
       "rating": { 
        "type": "double" 
       }, 
       "price": { 
        "type": "double" 
       }, 
       "rentPrice": { 
        "type": "double" 
       }, 
       "quantity": { 
        "type": "double" 
       }, 
       "format": { 
        "type": "string" 
       }, 
       "offer": { 
        "type": "double" 
       }, 
       "offerString": { 
        "type": "string" 
       }, 
       "language": { 
        "type": "string" 
       } 
      } 
     } 
    } 
}, function(err, mapping) { 
    if (err) { 
     console.log('error creating mapping (you can safely ignore this)'); 
     console.log(err); 
    } else { 
     console.log('mapping created!'); 
     console.log(mapping); 
    } 
}); 
+0

Спасибо за ваш ответ. Меня устраивает. –

Смежные вопросы