首页 > 解决方案 > Elasticsearch 按匹配过滤文档

问题描述

我有三个索引

产品索引结构

product:
        properties:
                    brand:
                        type: "nested"
                        properties:
                            id:
                                type: integer
                            name:
                                type: text
                    model:
                        type: "nested"
                        properties:
                            id:
                                type: integer
                            name:
                                type: text

    model:
        types:
            model:
                properties:
                    name: ~
                    brand: ~

模型数据集

[
    {
            "_index": "app_model",
            "_type": "model",
            "_id": "14",
            "_score": 1.0,
            "_source": {
                "name": "Saxonia",
                "brand": "A. Lange & Söhne"
            }
        },
        {
            "_index": "app_model",
            "_type": "model",
            "_id": "19",
            "_score": 1.0,
            "_source": {
                "name": "LS8",
                "brand": "Arman Nicolet"
            }
        }
]

品牌数据集

[
    {
        "_index": "app_brand",
        "_type": "brand",
        "_id": "14",
        "_score": 1.0,
        "_source": {
            "name": "A. Lange & Söhne"
        }
    },
    {
        "_index": "app_brand",
        "_type": "brand",
        "_id": "19",
        "_score": 1.0,
        "_source": {
            "name": "Arman Nicolet"
        }
    }
]

我需要同时搜索型号和品牌。例如:用户输入查询“A. Lange & Söhne”,然后我们给他以下结果(假设我们已经实现了带有错误搜索的部分):

标签: elasticsearch

解决方案


推荐阅读