Created
December 17, 2013 19:52
-
-
Save andrewvc/8011463 to your computer and use it in GitHub Desktop.
A short fuzzy search example, taken from http://www.found.no/foundation/fuzzy-search/
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
_type: product | |
name: Vacuum Cleaner | |
--- | |
_type: product | |
name: Turkey Baster |
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
product: | |
properties: | |
name: | |
type: "string" | |
analyzer: "simple" |
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/bash | |
export ELASTICSEARCH_ENDPOINT="http://localhost:9200" | |
# Create indexes | |
curl -XPUT "$ELASTICSEARCH_ENDPOINT/play" -d '{ | |
"settings": {}, | |
"mappings": { | |
"product": { | |
"properties": { | |
"name": { | |
"type": "string", | |
"analyzer": "simple" | |
} | |
} | |
} | |
} | |
}' | |
# Index documents | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_bulk?refresh=true" -d ' | |
{"index":{"_index":"play","_type":"product"}} | |
{"name":"Vacuum Cleaner"} | |
{"index":{"_index":"play","_type":"product"}} | |
{"name":"Turkey Baster"} | |
' | |
# Do searches | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"match": { | |
"name": { | |
"query": "Vacuummm", | |
"fuzziness": 2, | |
"prefix_length": 1 | |
} | |
} | |
} | |
} | |
' | |
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
# Auto generated by Found's Play-tool at 2013-12-17T11:52:06-08:00 | |
version: 0 | |
title: Fuzzy Search Example | |
description: "A short fuzzy search example, taken from http://www.found.no/foundation/fuzzy-search/" |
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
query: | |
match: | |
name: | |
query: "Vacuummm" | |
fuzziness: 2 | |
prefix_length: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment