Created
September 1, 2015 18:34
-
-
Save Vineeth-Mohan/9cffabff7a985b523e31 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
if [ -z $1 ] ; then | |
echo "Please enter hostname" | |
exit | |
fi | |
hostname=$1 | |
curl -XDELETE "http://$hostname:9200/news" | |
echo | |
curl -X PUT "http://$hostname:9200/news" -d '{ | |
"index": { | |
"number_of_shards": 1, | |
"number_of_replicas": 1 | |
}, | |
"analysis":{ | |
"analyzer":{ | |
"flat" : { | |
"type" : "custom", | |
"tokenizer" : "keyword", | |
"filter" : "lowercase" | |
} | |
} | |
} | |
}' | |
echo | |
curl -X PUT "http://$hostname:9200/news/artcile/_mapping" -d '{ | |
"artcile" : { | |
"properties" : { | |
"title" : { "type" : "string" , "boost" : 2 }, | |
"content" : { "type" : "string" , "boost" : 10 } | |
} | |
} | |
}' | |
echo | |
curl -XPOST "http://$hostname:9200/news/artcile" -d '{ | |
"title" : "elephant are big", | |
"content" : "animals are big" | |
}' | |
echo | |
curl -XPOST "http://$hostname:9200/news/artcile" -d '{ | |
"title" : "animals are big", | |
"content" : "elephant are big" | |
}' | |
echo | |
sleep 2 | |
curl -XPOST 'http://localhost:9200/news/_search?pretty' -d '{ | |
"query": { | |
"match": { | |
"_all": "elephant" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./createTest.sh localhost
{"acknowledged":true}
{"acknowledged":true}
{"acknowledged":true}
{"_index":"news","_type":"artcile","_id":"AU-KMC_lZVOCDMrQ7UMu","_version":1,"created":true}
{"_index":"news","_type":"artcile","_id":"AU-KMC_zZVOCDMrQ7UMv","_version":1,"created":true}
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.5764985,
"hits" : [ {
"_index" : "news",
"_type" : "artcile",
"_id" : "AU-KMC_zZVOCDMrQ7UMv",
"_score" : 1.5764985,
"_source":{
"title" : "animals are big",
"content" : "elephant are big"
}
}, {
"_index" : "news",
"_type" : "artcile",
"_id" : "AU-KMC_lZVOCDMrQ7UMu",
"_score" : 0.3152997,
"_source":{
"title" : "elephant are big",
"content" : "animals are big"
}
} ]
}
}