Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created December 17, 2013 19:52
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 andrewvc/8011463 to your computer and use it in GitHub Desktop.
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/
_type: product
name: Vacuum Cleaner
---
_type: product
name: Turkey Baster
product:
properties:
name:
type: "string"
analyzer: "simple"
#!/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
}
}
}
}
'
# 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/"
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