Created
September 10, 2014 08:35
-
-
Save babadofar/191559b2634d3e863579 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
text: This text will be used if nothing else is specified. | |
analyzer: | |
myAnalyzer: | |
type: custom | |
tokenizer: whitespace | |
filter: | |
- lowercase | |
- reverse | |
metaphoneAnalyzer: | |
# Custom text here, since this makes more sense for this analyzer. | |
text: | |
- John Smith | |
- Jon Schmidth | |
- Eivind | |
- Øyvind | |
- Oivin | |
type: custom | |
tokenizer: standard | |
filter: | |
- double_metaphone # Defined below | |
filter: | |
double_metaphone: | |
type: phonetic | |
encoder: doublemetaphone |
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
name: John | |
--- | |
name: jonne | |
--- | |
name:: Jona | |
--- | |
name: jon | |
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
# Customize mappings. Note: All indexes get the same types. | |
person: | |
properties: | |
nickname: | |
type: string | |
# ^ Place your cursor within the nickname object in the analysis view to see how the | |
# sample values of that field get tokenized. | |
# Dynamic templates and multi fields are supported. | |
dynamic_templates: | |
- name: | |
match: "name.*" | |
mapping: | |
type: multi_field | |
fields: | |
double_metaphone: | |
type: string | |
analyzer: double_metaphone | |
exact: | |
type: string | |
index: not_analyzed | |
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": { | |
"analysis": { | |
"text": "This text will be used if nothing else is specified.", | |
"analyzer": { | |
"myAnalyzer": { | |
"type": "custom", | |
"tokenizer": "whitespace", | |
"filter": [ | |
"lowercase", | |
"reverse" | |
] | |
}, | |
"metaphoneAnalyzer": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": [ | |
"double_metaphone" | |
] | |
} | |
}, | |
"filter": { | |
"double_metaphone": { | |
"type": "phonetic", | |
"encoder": "doublemetaphone" | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"person": { | |
"properties": { | |
"nickname": { | |
"type": "string" | |
} | |
}, | |
"dynamic_templates": [ | |
{ | |
"name": { | |
"match": "name.*", | |
"mapping": { | |
"type": "multi_field", | |
"fields": { | |
"double_metaphone": { | |
"type": "string", | |
"analyzer": "double_metaphone" | |
}, | |
"exact": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
}' | |
# Index documents | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_bulk?refresh=true" -d ' | |
{"index":{"_index":"play","_type":"type"}} | |
{"name":"John"} | |
{"index":{"_index":"play","_type":"type"}} | |
{"name":"jonne"} | |
{"index":{"_index":"play","_type":"type"}} | |
{"name:":"Jona"} | |
{"index":{"_index":"play","_type":"type"}} | |
{"name":"jon"} | |
' | |
# Do searches | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"match": { | |
"name": { | |
"query": "jon", | |
"fuzziness": 0 | |
} | |
} | |
}, | |
"size": 4, | |
"explain": true | |
} | |
' | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"match": { | |
"name": { | |
"query": "jon", | |
"fuzziness": 1 | |
} | |
} | |
}, | |
"size": 4, | |
"explain": true | |
} | |
' | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"match": { | |
"name": { | |
"query": "jon", | |
"fuzziness": 2 | |
} | |
} | |
}, | |
"size": 2, | |
"explain": true | |
} | |
' | |
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 2014-09-10T10:35:38+02:00 | |
version: 0 | |
title: fuzzytest | |
description: "" |
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
# Sample searches. Press Ctrl-Enter to run. | |
# Press Shift-Enter to go to focused mode for the selected editor. | |
# Click "Help" for more shortcuts. | |
query: | |
match: | |
name: | |
query: jon | |
fuzziness: 0 | |
# You can specify other search options as well. | |
size: 4 | |
explain: true | |
--- | |
query: | |
match: | |
name: | |
query: jon | |
fuzziness: 1 | |
# You can specify other search options as well. | |
size: 4 | |
explain: true | |
--- | |
query: | |
match: | |
name: | |
query: jon | |
fuzziness: 2 | |
# You can specify other search options as well. | |
size: 2 | |
explain: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment