Skip to content

Instantly share code, notes, and snippets.

@mahnunchik
Created May 17, 2013 06:18
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 mahnunchik/5597267 to your computer and use it in GitHub Desktop.
Save mahnunchik/5597267 to your computer and use it in GitHub Desktop.
#!/bin/sh
curl -XDELETE 'http://localhost:9200/testindex'
echo "\nIndex deleted"
curl -XPOST 'http://localhost:9200/testindex' -d '{
"settings": {
"analysis": {
"analyzer": {
"en_ru_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "russian_morphology", "english_morphology", "my_stopwords"]
},
"tag_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": ["lowercase"]
}
},
"filter": {
"my_stopwords": {
"type": "stop",
"stopwords": "а,без,более,бы,был,была,были,было,быть,в,вам,вас,весь,во,вот,все,всего,всех,вы,где,да,даже,для,до,его,ее,если,есть,еще,же,за,здесь,и,из,или,им,их,к,как,ко,когда,кто,ли,либо,мне,может,мы,на,надо,наш,не,него,нее,нет,ни,них,но,ну,о,об,однако,он,она,они,оно,от,очень,по,под,при,с,со,так,также,такой,там,те,тем,то,того,тоже,той,только,том,ты,у,уже,хотя,чего,чей,чем,что,чтобы,чье,чья,эта,эти,это,я,a,an,and,are,as,at,be,but,by,for,if,in,into,is,it,no,not,of,on,or,such,that,the,their,then,there,thesethey,this,to,was,will,with"
}
}
}
},
"mappings" : {
"testtype" : {
"properties" : {
"text" : {
"type": "multi_field",
"path": "just_name",
"fields": {
"text": {"type" : "string", "analyzer": "en_ru_analyzer"},
"tags": {"type" : "string", "analyzer": "tag_analyzer"}
}
},
"created": {
type: "date"
},
"coordinates": {
"type": "geo_point",
"lat_lon": true
}
},
"_source" : {
"enabled" : true
},
"_id": {
"index": "not_analyzed"
}
}
}
}'
echo "\nIndex created"
curl -XPUT 'http://localhost:9200/testindex/testtype/1' -d '{
"_id": "1",
"created": "2012-01-01T17:00:00.000Z",
"coordinates": {
"lat": 1,
"lon": 1
},
"text": "У московского бизнесмена из автомобиля украли шесть миллионов рублей"
}' && echo
curl -XPUT 'http://localhost:9200/testindex/testtype/2' -d '{
"_id": "2",
"created": "2012-02-01T17:00:00.000Z",
"coordinates": {
"lat": 2,
"lon": 2
},
"text": "Креативное агентство Jvision, запустило сервис, способствующий развитию автомобильного туризма в России."
}' && echo
curl -XPUT 'http://localhost:9200/testindex/testtype/3' -d '{
"_id": "3",
"created": "2012-03-01T17:00:00.000Z",
"coordinates": {
"lat": 3,
"lon": 3
},
"text": "Просто авто"
}' && echo
curl -XPUT 'http://localhost:9200/testindex/testtype/4' -d '{
"_id": "4",
"created": "2012-04-01T17:00:00.000Z",
"coordinates": {
"lat": 4,
"lon": 4
},
"text": "Японские автомобили вновь заняли в США первые места в рейтингах"
}' && echo
curl -XPUT 'http://localhost:9200/testindex/testtype/5' -d '{
"_id": "5",
"created": "2012-05-01T17:00:00.000Z",
"coordinates": {
"lat": 5,
"lon": 5
},
"text": "Январский дефицит платежного баланса Японии превысил $5 млрд"
}' && echo
curl -XPUT 'http://localhost:9200/testindex/testtype/6' -d '{
"_id": "6",
"created": "2012-06-01T17:00:00.000Z",
"coordinates": {
"lat": 6,
"lon": 6
},
"text": "Японская корпорация Sony представила новый смартфон под названием Xperia Sola"
}' && echo
curl -XPUT 'http://localhost:9200/testindex/testtype/7' -d '{
"_id": "7",
"created": "2012-07-01T17:00:00.000Z",
"coordinates": null,
"text": "Без координат. Японская"
}' && echo
curl -XPOST 'http://localhost:9200/testindex/_refresh' && echo
#!/bin/sh
echo "\ntags не работает:"
curl -XPOST 'http://127.0.0.1:9200/testindex/testtype/_search?pretty' -d '{
"sort": [
{
"_id": {
"order": "desc"
}
}
],
"size": 20,
"query": {
"filtered": {
"query": {
"match": {
"tags": "Японская"
}
}
}
}
}'
echo "\ntext работает:"
curl -XPOST 'http://127.0.0.1:9200/testindex/testtype/_search?pretty' -d '{
"sort": [
{
"_id": {
"order": "desc"
}
}
],
"size": 20,
"query": {
"filtered": {
"query": {
"match": {
"text": "Японская"
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment