Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save imotov/4448954 to your computer and use it in GitHub Desktop.
Save imotov/4448954 to your computer and use it in GitHub Desktop.
curl -XDELETE localhost:9200/test-idx
echo
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"query_default": {
"type": "standard"
}
}
}
}
},
"mappings": {
"doc": {
"properties": {
"title": {"type": "string", "index": "analyzed"},
"description": {"type": "string", "index": "analyzed"},
"format": {"type": "string", "index": "not_analyzed", "include_in_all": false},
"indexable_content": {"type": "string", "index": "analyzed"}
}
}
}
}'
echo
curl -XPUT localhost:9200/test-idx/doc/1 -d '{
"format": "test1",
"title": "blah",
"description": "blah",
"indexable_content": "keywords here"
}'
echo
curl -XPUT localhost:9200/test-idx/doc/2 -d '{
"format": "test3",
"title": "blah",
"description": "blah",
"indexable_content": "keywords here"
}'
curl -XPOST localhost:9200/test-idx/_refresh
curl -XPOST "localhost:9200/test-idx/doc/_search?pretty=true&explain=true" -d '{
"from": 0,
"query": {
"custom_filters_score": {
"filters": [
{
"boost": 1.5,
"filter": {
"term": {
"format": "test1"
}
}
},
{
"boost": 1.5,
"filter": {
"term": {
"format": "test2"
}
}
}
],
"query": {
"bool": {
"must": {
"query_string": {
"analyzer": "query_default",
"fields": [
"title^5",
"description^2",
"indexable_content"
],
"query": "blah"
}
},
"should": []
}
}
}
},
"size": 50
}'
curl -XPOST "localhost:9200/test-idx/doc/_search?pretty=true" -d '
{
"from": 0,
"query": {
"bool": {
"must": [{
"query_string": {
"analyzer": "query_default",
"fields": ["title^5", "description^2", "indexable_content"],
"query": "blah"
}
}, {
"term": {
"format": "test1"
}
}]
}
},
"size": 50
}
'
@thanghv55
Copy link

Hi Igor Motov,

thanks for your's example. I executed that example, however i can not run the query:
curl -XPOST "localhost:9200/test-idx/doc/_search?pretty=true&explain=true" -d '{
"from": 0,
"query": {
"custom_filters_score": {
"filters": [
{
"boost": 1.5,
"filter": {
"term": {
"format": "test1"
}
}
},
{
"boost": 1.5,
"filter": {
"term": {
"format": "test2"
}
}
}
],
"query": {
"bool": {
"must": {
"query_string": {
"analyzer": "query_default",
"fields": [
"title^5",
"description^2",
"indexable_content"
],
"query": "blah"
}
},
"should": []
}
}
}
},
"size": 50
}'
it made error "QueryParsingException[[test-idx] No query registered for [custom_filters_score]]; }]","
i have tried with elasticsearch verison 1.4.4 and 0.90.10
Please help me!
thanks!

Thang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment