Hi, I am new to Mongoosastic and elastic search. Just want to understand the following:
var companySchema = new Schema ({
name: {type:String,required:true, es_indexed:true},
address :[{line1: {type:String,required:true},
line2: String,
city: {type:String,required:true,es_indexed:true},
state: {type:String,required:true,es_indexed:true},
country: {type: String,required:true, default: 'India'},
zip: {type:String,required:true,es_indexed:true},
location: {
geo_point: {
type: String,
es_type: 'geo_point',
es_lat_lon: true,
es_indexed: true,
es_format: "compressed",
es_precision: "1km"
},
lat: { type: Number},
lon: { type: Number}
},
registration_location: {
lat: { type: Number},
lon: { type: Number}
},
isVerificationNeeded: {type:Boolean,required:true, default: false},
isVerified: Boolean,
isActive: {type: Boolean,required:true, default: true}
}],
categoriesDealIn: [{type: Schema.Types.ObjectId,required:true, ref: 'Category',es_indexed:true}],
classificationCategories: [{type: String,required:true, ref: 'ClassificationCategory',es_indexed:true}]
});
this generates
"mappings" : {
"company" : {
"properties" : {
"address" : {
"properties" : {
"city" : {
"type" : "string"
},
"location" : {
"properties" : {
"lat" : {
"type" : "long"
},
"lon" : {
"type" : "long"
}
}
},
"state" : {
"type" : "string"
},
"zip" : {
"type" : "string"
}
}
},
"categoriesDealIn" : {
"type" : "string"
},
"classificationCategories" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
}
}
}
where as we need
{
"instafind" : {
"aliases" : { },
"mappings" : {
"company" : {
"properties" : {
"address" : {
"type" : "nested",
"properties" : {
"city" : {
"type" : "string"
},
"location" : {
"type" : "geo_point",
"fielddata" : {
"precision" : "1km",
"format" : "compressed"
}
},
"state" : {
"type" : "string"
},
"zip" : {
"type" : "string"
}
}
},
"categoriesDealIn" : {
"type" : "string"
},
"classificationCategories" : {
"type" : "string"
},
"name" : {
"type" : "string",
"index_analyzer" : "autocomplete",
"search_analyzer" : "standard"
},
}
}
},
"settings" : {
"index" : {
"creation_date" : "1426258942277",
"uuid" : "7Y6j_XgeSau2BdCFSuU6jQ",
"analysis" : {
"analyzer" : {
"autocomplete" : {
"type" : "custom",
"filter" : [ "lowercase", "autocomplete_filter" ],
"tokenizer" : "standard"
}
},
"filter" : {
"autocomplete_filter" : {
"min_gram" : "2",
"type" : "edge_ngram",
"max_gram" : "20"
}
}
},
"number_of_replicas" : "1",
"number_of_shards" : "1",
"version" : {
"created" : "1040499"
}
}
},
"warmers" : { }
}
}
Can you please elaborate what changes we need to do in our javascript code for the same?
Similarly, we have classification schema:
var classificationSchema = new Schema({
_id: {type:String, es_indexed:true}, //path ->
name: {type:String,required:true, es_indexed:true}
});
We want to do autocomplete filter for _id field here too? How can that be achieved?
Thanks!