Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Created November 12, 2015 09:22
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 PirosB3/8e93ca5236d395c3954d to your computer and use it in GitHub Desktop.
Save PirosB3/8e93ca5236d395c3954d to your computer and use it in GitHub Desktop.
# Let's start by checking how many documents we have in the collection
GET /bank/account/_count
# A simple search. The word "Michael" must be fully conatiend somewhere in the specified field.
# A score is given to each document retrieved
GET /bank/account/_search
{
"query": {
"match": {
"address": "Temple Court"
}
}
}
# We can use match_phrase if we want to be a bit more precise. This will only match document addresses that contain "Temple Court"
GET /bank/account/_search
{
"query": {
"match_phrase": {
"address": "Temple Court"
}
}
}
# A simple search. The word "Michael" must be fully conatiend somewhere in the specified field.
# A score is given to each document retrieved
GET /bank/account/_search
{
"query": {
"match": {
"address": "Temple Court"
}
}
}
# We can use match_phrase if we want to be a bit more precise. This will only match document addresses that contain "Temple Court"
GET /bank/account/_search
{
"query": {
"multi_match" : {
"query": "temple",
"fields": [ "address", "lastname"]
}
}
}
# Never assume human imput! that's why we want to perform a fuzzy search at times
GET /bank/account/_search
{
"query": {
"fuzzy": {
"address": {
"value": "tmple",
"fuzziness": 2
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment