在Elasticsearch 6.3中,我试图在嵌套对象字段中应用bigram查询,该查询对象字段通过组合嵌套字段中的所有值来生成bigram数据。下面是映射。
PUT /testindex
{
"settings": {
"analysis": {
"analyzer": {
"my_shingles_test": {
"tokenizer": "standard",
"filter": [
"shingles"
]
}
},
"filter": {
"shingles": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 3,
"output_unigrams": false
}
}
}
},
"mappings": {
"default" :{
"properties" : {
"book_name":{
"type":"text"
},
"book_id":{
"type": "integer"
},
"book_attributes":{
"type":"nested",
"properties": {
"search_term":{
"type":"nested"
"analyzer": "my_shingles_test"
}
}
}
}
Here's the sample data:
{
"book_name":"xyz",
"book_id":123,
"book_attributes":[
{
"search_term":[
"paperback"
]
},
{
"search_term":[
"best selling"
]
}
]
},
{
"book_name":"abc",
"book_id":456,
"book_attributes":[
{
"search_term":[
"hardcover"
]
},
{
"search_term":[
"best author"
]
},
{
"search_term":[
"best selling"
]
}
]
}
在这里,我想为文档的所有搜索词创建bigram和trigram作为[平装本,最畅销,平装本最畅销]。当某人搜索平装书畅销书时,它应该只退回ID为123的书。我尝试过,但未返回预期结果。