Skip to content

Instantly share code, notes, and snippets.

@ericnormand
Created February 19, 2015 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericnormand/38de4a6be13698c7e1a1 to your computer and use it in GitHub Desktop.
Save ericnormand/38de4a6be13698c7e1a1 to your computer and use it in GitHub Desktop.
Elasticsearch Help
{
"big-feed-index": {
"mappings": {
"listings": {
"properties": {
"asin": {
"type": "string",
"index": "not_analyzed"
},
"categories": {
"properties": {
"path": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
},
"name": {
"type": "string",
"analyzer": "english"
}
}
}
}
},
"description": {
"type": "string",
"analyzer": "english"
},
"ean": {
"type": "string",
"index": "not_analyzed"
},
"fqdn": {
"type": "string"
},
"id": {
"type": "string",
"index": "not_analyzed"
},
"image": {
"type": "string"
},
"isbn": {
"type": "string",
"index": "not_analyzed"
},
"manufacturer": {
"type": "string",
"analyzer": "english"
},
"mpn": {
"type": "string",
"index": "not_analyzed"
},
"name": {
"type": "string",
"analyzer": "english"
},
"not-active?": {
"type": "boolean"
},
"prefix": {
"type": "string",
"index": "not_analyzed"
},
"price": {
"type": "long"
},
"rating": {
"type": "double"
},
"retailer": {
"type": "string"
},
"reviews-count": {
"type": "long"
},
"shipping": {
"type": "long"
},
"sku": {
"type": "string",
"index": "not_analyzed"
},
"timestamp": {
"type": "date",
"format": "dateOptionalTime"
},
"upc": {
"type": "string",
"index": "not_analyzed"
},
"updated": {
"type": "date",
"format": "dateOptionalTime"
},
"url": {
"type": "string"
}
}
}
}
}
}
{"query":
{"bool":
{"should": [{"multi_match":
{"use_dis_max": true,
"query": "18 Paper Cutter Trimmer Craft Scrap Booking Desktop Guillotine Sheet Photo Desk",
"tie_breaker": 0.3,
"fields": ["categories.path.name", "description", "name^3"]}},
{"multi_match":
{"use_dis_max": true,
"query": "Business & Industrial",
"fields": ["categories.path.name^2", "description", "name"]}},
{"multi_match":
{"use_dis_max": true,
"query": "Direct Value",
"fields": ["manufacturer^2", "name", "description"]}}],
"must": [{"multi_match":
{"use_dis_max": true,
"query": "18 Paper Cutter Trimmer Craft Scrap Booking Desktop Guillotine Sheet Photo Desk",
"tie_breaker": 0.3,
"fuzziness": "AUTO",
"fields": ["categories.path.name", "description", "name^3"]}}]}}}
{
"_index": "big-feed-index",
"_type": "listings",
"_id": "walmart--1072864_1044263--21400658",
"_score": 1,
"_source": {
"not-active?": false,
"timestamp": "20150217T17:30:08+0000",
"shipping": 499,
"upc": "661588075295",
"fqdn": "www.walmart.com",
"prefix": "walmart-1072864",
"name": "Heininger Holdings LLC Nannini Compact One Reading Glasses Optics 3.0",
"image": "http://i.walmartimages.com/i/mp/00/66/15/88/07/0066158807504_P255045_500X500.jpg",
"url": "http://linksynergy.walmart.com/fs-bin/click?id=lS/InECdna4&offerid=223073.7200&type=14&catid=8&subid=0&hid=7200&tmpid=1082&RD_PARM1=http%253A%252F%252Fwww.walmart.com%252Fip%252FHeininger-Holdings-LLC-Nannini-Compact-One-Reading-Glasses-Optics-3.0%252F21400658%253Faffp1%253D%257Capk%257C%2526affilsrc%253Dapi",
"sku": "21400658",
"price": 3999,
"id": "walmart--1072864_1044263--21400658",
"retailer": "www.walmart.com"
}
},
@drewr
Copy link

drewr commented Feb 20, 2015

Adding a reformatted query to make sure I'm seeing it right:

{
    "query": {
        "bool": {
            "must": [
                {
                    "multi_match": {
                        "fields": [
                            "categories.path.name",
                            "description",
                            "name^3"
                        ],
                        "fuzziness": "AUTO",
                        "query": "18 Paper Cutter Trimmer Craft Scrap Booking Desktop Guillotine Sheet Photo Desk",
                        "tie_breaker": 0.3,
                        "use_dis_max": true
                    }
                }
            ],
            "should": [
                {
                    "multi_match": {
                        "fields": [
                            "categories.path.name",
                            "description",
                            "name^3"
                        ],
                        "query": "18 Paper Cutter Trimmer Craft Scrap Booking Desktop Guillotine Sheet Photo Desk",
                        "tie_breaker": 0.3,
                        "use_dis_max": true
                    }
                },
                {
                    "multi_match": {
                        "fields": [
                            "categories.path.name^2",
                            "description",
                            "name"
                        ],
                        "query": "Business & Industrial",
                        "use_dis_max": true
                    }
                },
                {
                    "multi_match": {
                        "fields": [
                            "manufacturer^2",
                            "name",
                            "description"
                        ],
                        "query": "Direct Value",
                        "use_dis_max": true
                    }
                }
            ]
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment