您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

MySQL查询到ElasticSearch

MySQL查询到ElasticSearch

您正在使事情变得复杂,并试图在Elasticsearch中适应MysqL概念。在这种情况下,您需要正确定义索引映射(根据搜索要求来字段数据类型及其分析器),并相应地构建查询

我已经获取了您的示例,并且没有更改索引映射和示例文档,但是更改了搜索查询显示如何处理现有数据和需求(可能无法在所有情况下都有效,但是您有所了解)搜索

{
    "query": {
        "multi_match": { --> note and read about multi_match query
            "query": "36695",
            "fields": [
                "address",
                "city_code", --> add more fields if you need to be
                "zip_code",
                "contact_no"
            ]
        }
    }
}

 "hits": [
            {
                "_index": "so_MysqL_dsl",
                "_type": "_doc",
                "_id": "1",
                "_score": 0.2876821,
                "_source": {
                    "promotion": null,
                    "image": null,
                    "name": "Port City Realty",
                    "city_code": "Mobile",
                    "services": null,
                    "promotion_exp_date": null,
                    "tuesdayopen": null,
                    "tuesdayclose": null,
                    "wednesdayopen": null,
                    "thursdayclose": null,
                    "@timestamp": "2020-03-13T15:44:45.330Z",
                    "date_updated": "2020-03-06T00:00:00.000Z",
                    "mondayopen": null,
                    "contact_no": "2516891228",
                    "id": 1941,
                    "fridayclose": null,
                    "featured": 0,
                    "main_cate": 1,
                    "wednesdayclose": null,
                    "sundayopen": null,
                    "state_code": "AL",
                    "video": null,
                    "address": "4826 Whispering Oaks Lane",
                    "user_id": null,
                    "slug": "2516891228-port-city-realty-mobile-al-36695",
                    "timezone": null,
                    "source": "USA Business",
                    "description": null,
                    "fridayopen": null,
                    "price": null,
                    "saturdayopen": null,
                    "saturdayclose": null,
                    "date_added": "2020-03-05T19:00:00.000Z",
                    "thursdayopen": null,
                    "@version": "1",
                    "status": 1,
                    "mondayclose": null,
                    "zip_code": "36695",
                    "private_contact": null,
                    "location_id": 0,
                    "sundayclose": null
                }
            }
        ]
MySQL 2022/1/1 18:16:32 有438人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶