你好,斯塔克·Overflowers,
我有几十万个文档,结构如下。我可以在加载到Elasticsearch之前修改文档,比如添加向量、同义词或其他注解。请假设所有文档都有很好的属性。属性根据产品的类别而变化。
- 如果有一个查询,我希望显示查询的精确产品。例如,如果有人搜索“Lee jeans”,我希望显示品牌“Lee”的所有产品,这些产品都是“Jeans”。
- 如果用户搜索“Lee black jeans”,我希望通过变体“Black”过滤掉
- 如果用户搜索“Lee spring summer jeans”,那么我只想显示以下产品。
- 它应该能够理解排印错误
- 它应该进行分类。例如,“巧克力牛奶”是“牛奶”,“牛奶巧克力”是“巧克力”。
我已经看到了一些方法在互联网上(一些项目已经过时或不再维护),但我希望建议开发人员社区在这里什么开源解决方案,我可以使用,以及什么是我应该做的改变,以实现这一点之前,加载到Elasticsearch的文档。
{
"product_id": 489929,
"name_en": "Spring Summer Jeans",
"attributes": {
"category": "Pants",
"type": [
"Jeans",
"Denim"
],
"brand": "Lee",
"material": [
"Cotton"
]
},
"variants": {
"size": [
28,
30,
32,
34,
36
],
"colors": [
"Blue",
"Black"
],
"fit": [
"Regular",
"Narrow"
],
"gender": [
"Men",
"Women"
]
},
"description_en": "Quick brown fox jumps over the lazy dog.",
"variant_ids": {
"1467547": {
"size": 30,
"color": "Black",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"7487751": {
"size": 32,
"color": "Blue",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"11089927": {
"size": 32,
"color": "Blue",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"11258137": {
"size": 34,
"color": "Blue",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"13266321": {
"size": 30,
"color": "Black",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"13549929": {
"size": 30,
"color": "Blue",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"17846649": {
"size": 28,
"color": "Blue",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"22602397": {
"size": 36,
"color": "Blue",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"22709931": {
"size": 28,
"color": "Black",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"23937102": {
"size": 28,
"color": "Black",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"28519361": {
"size": 30,
"color": "Blue",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"31165878": {
"size": 36,
"color": "Black",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"31631591": {
"size": 30,
"color": "Blue",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"36914467": {
"size": 36,
"color": "Black",
"fit": "Regular",
"gender": "Men",
"in_stock": false
},
"39141069": {
"size": 28,
"color": "Blue",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"41416888": {
"size": 36,
"color": "Blue",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"43504246": {
"size": 34,
"color": "Black",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"45374599": {
"size": 34,
"color": "Blue",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"46361047": {
"size": 28,
"color": "Blue",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"46909634": {
"size": 32,
"color": "Black",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"49407526": {
"size": 32,
"color": "Black",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"54529078": {
"size": 34,
"color": "Black",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"55659499": {
"size": 28,
"color": "Blue",
"fit": "Narrow",
"gender": "Women",
"in_stock": false
},
"55762371": {
"size": 34,
"color": "Blue",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"57049076": {
"size": 36,
"color": "Black",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"57973674": {
"size": 36,
"color": "Black",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"58218538": {
"size": 28,
"color": "Black",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"58227462": {
"size": 30,
"color": "Blue",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"58232621": {
"size": 30,
"color": "Black",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"59320783": {
"size": 30,
"color": "Black",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"63244508": {
"size": 32,
"color": "Black",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"66194331": {
"size": 36,
"color": "Blue",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"71212553": {
"size": 32,
"color": "Blue",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"84143801": {
"size": 34,
"color": "Black",
"fit": "Narrow",
"gender": "Men",
"in_stock": true
},
"86881320": {
"size": 34,
"color": "Blue",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"89177537": {
"size": 32,
"color": "Black",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"90449959": {
"size": 36,
"color": "Blue",
"fit": "Narrow",
"gender": "Women",
"in_stock": true
},
"92989653": {
"size": 34,
"color": "Black",
"fit": "Regular",
"gender": "Men",
"in_stock": true
},
"93319121": {
"size": 32,
"color": "Blue",
"fit": "Regular",
"gender": "Women",
"in_stock": true
},
"95212291": {
"size": 28,
"color": "Black",
"fit": "Regular",
"gender": "Men",
"in_stock": true
}
}
}
1条答案
按热度按时间4bbkushb1#
Elasticsearch不支持OOTB NLP。最近,他们在版本8中包含了特性,但它需要许可证版本的Elasticsearch。而且,似乎到目前为止,你只能在索引时使用Ingest管道,但在查询时,你需要编写自定义 Package 器来实现这一点。你可以阅读我的文章here,了解如何在索引时使用。
您可以将下面的
multi_match
查询与cross_field
一起使用,并将当前索引Map用于前3个用例,它将在不集成任何NLP的情况下为您提供预期结果。带有交叉字段的
multi_match
不支持模糊查询,因此它不能用于usecase 4的上述查询。您可以阅读this答案,该答案显示了如何使用copy_to
并创建一个带有所有值的字段并应用模糊性。您可以在上述查询中添加带有bool
子句的相同查询。如下所示:Usecase 5与lemmatize无关,但它是usecase同义词您可以为'Chocolate milk'是'Milk','Milk chocolate'是'Chocolate'和所有其他单词配置同义词,并使用自定义分析器在索引时或查询时应用您可以阅读有关同义词here信息