-
-
Save imotov/b62f45dcf28a5c030e67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
curl -XDELETE localhost:9200/relevance | |
echo | |
curl -XPUT localhost:9200/relevance -d '{ | |
"settings" : { | |
"index" : { | |
"number_of_shards" : 1, | |
"number_of_replicas" : 0 | |
} | |
}, | |
"mappings" : { | |
"doc" : { | |
"properties" : { | |
"name" : { | |
"type" : "string" | |
}, | |
"category" : { | |
"type" : "string" | |
}, | |
"cuisine" : { | |
"type" : "string" | |
}, | |
"address" : { | |
"type" : "string" | |
}, | |
"tags" : { | |
"type" : "string" | |
} | |
} | |
} | |
} | |
}' | |
echo | |
curl -XPUT localhost:9200/relevance/doc/1 -d '{ | |
"name": "Bravo Pizza", | |
"category": "Restaurant", | |
"cuisine": "Italian", | |
"address": "146 5th Avenue #1 New York, NY 10011", | |
"tags": ["catering", "take-out"] | |
}' | |
echo | |
curl -XPUT localhost:9200/relevance/doc/2 -d '{ | |
"name": "L a Cafe", | |
"category": "Sandwich Shop", | |
"cuisine": "Italian", | |
"address": "200 5th Avenue New York, NY 10011", | |
"tags": ["wifi", "take-out"] | |
}' | |
echo | |
curl -XPUT localhost:9200/relevance/doc/3 -d '{ | |
"name": "Birreria", | |
"category": "Restaurant", | |
"cuisine": "Italian", | |
"address": "200 5th Avenue New York, NY 10011" | |
}' | |
echo | |
curl -XPUT localhost:9200/relevance/doc/4 -d '{ | |
"name": "Empire Pizza", | |
"category": "Restaurant", | |
"cuisine": "Italian", | |
"address": "314 5th Avenue New York, NY 10001", | |
"tags": ["24 hours", "wifi"] | |
}' | |
echo | |
curl -XPUT localhost:9200/relevance/doc/5 -d '{ | |
"name": "Tarallucci e Vino", | |
"category": "Restaurant", | |
"cuisine": "Italian", | |
"address": "15 East 18th Street Manhattan, NY 10003", | |
"tags": ["hip", "panini", "wifi", "small plates"] | |
}' | |
echo | |
curl -XPUT localhost:9200/relevance/doc/6 -d '{ | |
"name": "Ceci Italian Cuisine", | |
"category": "Restaurant", | |
"cuisine": "Italian", | |
"address": "46 West 46th Street New York, NY 10036", | |
"tags": ["fried calamari", "osso bucco", "amazing food", "lamb chops"] | |
}' | |
echo | |
curl -XPOST localhost:9200/relevance/_refresh | |
echo | |
curl "localhost:9200/relevance/doc/_search?pretty=true&explain=false" -d '{ | |
"query" : { | |
"bool" : { | |
"should": [ | |
{ | |
"match": { | |
"name": { | |
"query":"italian restaurant with wifi at 5th avenue", | |
"boost": 4.0 | |
} | |
} | |
}, | |
{ | |
"match": { | |
"category": { | |
"query":"italian restaurant with wifi at 5th avenue", | |
"boost": 2.0 | |
} | |
} | |
}, | |
{ | |
"match": { | |
"cuisine": { | |
"query":"italian restaurant with wifi at 5th avenue", | |
"boost": 2.0 | |
} | |
} | |
}, | |
{ | |
"match": { | |
"address": { | |
"query":"italian restaurant with wifi at 5th avenue", | |
"boost": 1.0 | |
} | |
} | |
}, | |
{ | |
"match": { | |
"tags": { | |
"query":"italian restaurant with wifi at 5th avenue", | |
"boost": 2.0 | |
} | |
} | |
} | |
] | |
} | |
}, | |
"fields": ["name", "category", "cuisine", "address", "tags"] | |
}' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment