思路:
将嵌套对象转成json格式(嵌套对象的字段不多可以这样用,字段的很多的话,可将其转换成md5),如果有多个嵌套对象,他们直接可以用空格进行隔开。分词器使用whitespace。
#注意分词器使用whitespace
{
"usersnew" : {
"mappings" : {
"properties" : {
"content" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "whitespace"
},
"firstName" : {
"type" : "text"
},
"lastName" : {
"type" : "keyword",
"null_value" : "jack"
},
"mobile" : {
"type" : "text",
"index" : false
}
}
}
}
}
#查询时分词器也要使用whitespace, operator为and表示两个词之间的关系为且
POST usersnew/_search
{
"query": {
"match": {
"content": {
"query": "address:高科利 job:产品",
"analyzer": "whitespace",
"operator": "and"
}
}
}
}
实验测试下两个数据结构对查询性能影响的差别