Skip to content

Instantly share code, notes, and snippets.

Created May 14, 2013 09:35
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 anonymous/5574793 to your computer and use it in GitHub Desktop.
Save anonymous/5574793 to your computer and use it in GitHub Desktop.
Mapping
state: open
settings: {
index.analysis.analyzer.myEdgeNGramAnalyzer.filter.1: lowercase
index.analysis.filter.myEdgeNGram.type: edgeNGram
index.analysis.analyzer.myEdgeNGramAnalyzer.filter.0: standard
index.analysis.analyzer.myEdgeNGramAnalyzer.filter.3: myEdgeNGram
index.analysis.analyzer.myEdgeNGramAnalyzer.filter.2: asciifolding
index.analysis.filter.myEdgeNGram.max_gram: 8
index.analysis.filter.myEdgeNGram.min_gram: 2
index.analysis.analyzer.myEdgeNGramAnalyzer.tokenizer: standard
index.analysis.analyzer.myEdgeNGramAnalyzer.type: custom
index.number_of_shards: 5
index.number_of_replicas: 1
index.version.created: 900099
}
mappings: {
taxonomy: {
properties: {
category: {
analyzer: myEdgeGNramAnalyzer
boost: 5
type: string
}
brand: {
analyzer: myEdgeNGramAnalyzer
boost: 3
type: string
}
slug: {
type: string
}
}
}
}
aliases: []
}
-------------------------------------------
Query
This is the query that I am executing. I have no other choice then querying on brand and category, as I don't know which type of information is searched by the user.
curl -X GET 'http://localhost:9200/dscuento_com/_search?pretty=true' -d '
{
"query": {
"dis_max": {
"queries": [
{
"field": {
"brand": "Moda"
}
},
{
"field": {
"category": "Moda"
}
}
]
}
}
}'
-------------------------------------------
Result
{
"took" : 23,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 9,
"max_score" : 12.586615,
"hits" : [ {
"_index" : "dscuento_com",
"_type" : "taxonomy",
"_id" : "QYGfi7a5TCikkR3gPuaU9g",
"_score" : 12.586615, "_source" : {"id":1, "category":"Moda","brand":"Kappa"}
}, {
"_index" : "dscuento_com",
"_type" : "taxonomy",
"_id" : "-Z1Li8oPSOGJLS-9H2bmDQ",
"_score" : 10.339577, "_source" : {"id":90, "category":"Moda","brand":"Mazine"}
}, {
"_index" : "dscuento_com",
"_type" : "taxonomy",
"_id" : "Vbmzm0j7QPG-jDmoSvG0Bw",
"_score" : 7.505477, "_source" : {"id":4,"category":"Moda"}
}
Here is actually my problem : I would like the third document having the highest score, as it only have the field "category" that matches and no other additional fields declared.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment