Created
January 18, 2017 08:10
-
-
Save spinscale/706e137bdc08f384e179460ced64034f to your computer and use it in GitHub Desktop.
Queries vom Training
This file contains hidden or 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
DELETE _all | |
GET index/_mapping | |
PUT index | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"my_analyzer": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"char_filter": [ | |
"my_char_filter" | |
] | |
} | |
}, | |
"char_filter": { | |
"my_char_filter": { | |
"type": "html_strip" | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"type": { | |
"properties": { | |
"html": { | |
"type": "text", | |
"fields": { | |
"plain": { | |
"type": "text", | |
"analyzer": "my_analyzer" | |
}, | |
"fvh": { | |
"type": "text", | |
"analyzer": "my_analyzer", | |
"term_vector": "yes" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
PUT index/type/1 | |
{ | |
"html" : "<html><head><title>Hello this is a title</title></head><body>This is a body, which is pretty amazing</body></html>" | |
} | |
GET index/type/_search | |
{ | |
"query": { | |
"match": { | |
"html": "body" | |
} | |
}, | |
"highlight": { | |
"fields": { | |
"html" : {} | |
} | |
} | |
} | |
GET index/type/_search | |
{ | |
"query": { | |
"match": { | |
"html.plain": "body" | |
} | |
}, | |
"highlight": { | |
"fields": { | |
"html.plain" : {} | |
} | |
} | |
} | |
GET index/type/_search | |
{ | |
"query": { | |
"match": { | |
"html.fvh": "body" | |
} | |
}, | |
"highlight": { | |
"fields": { | |
"html.fvh" : {} | |
} | |
} | |
} | |
# bin/elasticsearch-plugin install analysis-phonetic | |
DELETE phonetic_sample | |
PUT phonetic_sample | |
{ | |
"mappings": { | |
"person" : { | |
"properties": { | |
"name" : { | |
"type": "text", | |
"analyzer": "my_analyzer", | |
"fields": { | |
"koelner" : { | |
"type": "text", | |
"analyzer": "koelner_analyzer" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"settings": { | |
"index": { | |
"analysis": { | |
"analyzer": { | |
"my_analyzer": { | |
"tokenizer": "standard", | |
"filter": [ | |
"standard", | |
"lowercase", | |
"my_metaphone" | |
] | |
}, | |
"koelner_analyzer": { | |
"tokenizer": "standard", | |
"filter": [ | |
"standard", | |
"lowercase", | |
"koelner_metaphone" | |
] | |
} | |
}, | |
"filter": { | |
"my_metaphone": { | |
"type": "phonetic", | |
"encoder": "metaphone", | |
"replace": false | |
}, | |
"koelner_metaphone": { | |
"type": "phonetic", | |
"encoder": "koelnerphonetik", | |
"replace": false | |
} | |
} | |
} | |
} | |
} | |
} | |
POST phonetic_sample/_analyze | |
{ | |
"analyzer": "my_analyzer", | |
"text": "Joe Blocks" | |
} | |
POST phonetic_sample/_analyze | |
{ | |
"analyzer": "koelner_analyzer", | |
"text": "Aleksander" | |
} | |
PUT phonetic_sample/person/1 | |
{ | |
"name" : "Peter Meyer" | |
} | |
PUT phonetic_sample/person/2 | |
{ | |
"name" : "Peter Meier" | |
} | |
PUT phonetic_sample/person/3 | |
{ | |
"name" : "Peter Maier" | |
} | |
PUT phonetic_sample/person/4 | |
{ | |
"name" : "Peter Mayer" | |
} | |
GET phonetic_sample/_search | |
{ | |
"query": { | |
"match": { | |
"name": "Maier" | |
} | |
} | |
} | |
GET phonetic_sample/_search | |
{ | |
"query": { | |
"match": { | |
"name.koelner": "Maier" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment