-
-
Save karmi/990774 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
# ======================================== | |
# Testing multiple analyzers per field | |
# ======================================== | |
# Setup | |
curl -s -X DELETE 'http://localhost:9200/news_test/' | |
# Create index with settings and mapping | |
curl -s -X PUT 'http://localhost:9200/news_test' -d ' | |
{ | |
"settings" : { | |
"index" : { | |
"analysis" : { | |
"analyzer" : { | |
"czech_ascii" : { | |
"type" : "custom", | |
"tokenizer" : "standard", | |
"filter" : ["asciifolding", "lowercase", "czech_stem"] | |
} | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"message" : { | |
"properties" : { | |
"body" : { | |
"type" : "multi_field", | |
"fields" : { | |
"body" : {"type" : "string", "index" : "analyzed", "analyzer" : "keyword" }, | |
"body.czech" : {"type" : "string", "index" : "analyzed", "analyzer" : "czech" }, | |
"body.czech.ascii" : {"type" : "string", "index" : "analyzed", "analyzer" : "czech_ascii"}, | |
"body.english" : {"type" : "string", "index" : "analyzed", "analyzer" : "snowball"} | |
} | |
} | |
} | |
} | |
} | |
}' | |
# Refresh indices | |
curl -s -X POST 'http://localhost:9200/news_test/_refresh' | |
# Create documents | |
curl -s -X POST 'http://localhost:9200/news_test/message' -d '{"body":"stromeček"}' | |
curl -s -X POST 'http://localhost:9200/news_test/message' -d '{"body":"tree"}' | |
curl -s -X POST 'http://localhost:9200/news_test/_refresh' | |
echo; echo; echo '>>> Search for trees' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body.*"], | |
"query":"trees" | |
} | |
} | |
}' | |
echo; echo; echo '>>> Search for stromečky' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body.*"], | |
"query":"stromečky" | |
} | |
} | |
}' | |
echo; echo; echo '>>> Search for stromecky' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body.*"], | |
"query":"stromecky" | |
} | |
} | |
}' | |
echo; echo; echo '>>> Search for stromeček' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body.*"], | |
"query":"stromeček" | |
} | |
} | |
}' | |
echo; echo; echo '>>> Search for tree' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body.*"], | |
"query":"tree" | |
} | |
} | |
}' | |
echo; echo; echo '>>> Search for trees only in "exact" field' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body"], | |
"query":"trees" | |
} | |
} | |
}' | |
echo; echo; echo '>>> Search for stromečky in english field' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body.english"], | |
"query":"stromečky" | |
} | |
} | |
}' | |
echo; echo; echo '>>> Search for stromečky in czech.ascii field' | |
curl -s -X POST 'http://localhost:9200/news_test/_search?pretty=true' -d '{ | |
"query":{ | |
"query_string":{ | |
"fields" : ["body.czech.ascii"], | |
"query":"stromečky" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment