4

実際、いくつかのフィールドからインデックス作成を削除したいのですが、私のコードが以下に示されているマッピングを作成する方法を教えてください。これで何が問題なのか、または正しい方法を教えてください。それ。

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

});

前もって感謝します。

4

1 に答える 1

5

example : この例は映画情報を保存するためのものです

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);
    }
});
于 2016-03-29T05:20:02.490 に答える