Created
July 30, 2013 04:39
-
-
Save rashidkpc/6110289 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
# This command returns a terms facet of size 12 | |
# eg, every term in the terms index. Ordered by count they are: | |
# term12 (120) term11 (110) term10 (100) term9 (90) term8 (80) term7 (70) | |
# term6 (60) term5 (50) term4 (40) term3 (30) term2 (20) term1 (10) | |
curl -XGET 'http://localhost:9200/terms/_search?pretty' -d '{ | |
"facets": { | |
"terms": { | |
"terms": { | |
"field": "term", | |
"size": 12, | |
"order": "count", | |
"exclude": [] | |
}, | |
"facet_filter": { | |
"fquery": { | |
"query": { | |
"filtered": { | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"query_string": { | |
"query": "*" | |
} | |
} | |
] | |
} | |
}, | |
"filter": { | |
"bool": { | |
"must": [ | |
{ | |
"match_all": {} | |
}, | |
{ | |
"bool": { | |
"must": [ | |
{ | |
"match_all": {} | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"size": 0 | |
}' |
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
# This is the same terms facet, with a size of 5. | |
# It SHOULD return term12 (120) term11 (110) term10 (100) term9 (90) term8 (80) | |
# Instead it returns term12 (120) term11 (110) term9 (90) term10 (84) term8 (69) | |
# Note the complete count of terms 12,11 and 9, and the incomplete cunts of 10 and 8 | |
# and that 9 appears before 10. | |
curl -XGET 'http://localhost:9200/terms/_search?pretty' -d '{ | |
"facets": { | |
"terms": { | |
"terms": { | |
"field": "term", | |
"size": 5, | |
"order": "count", | |
"exclude": [] | |
}, | |
"facet_filter": { | |
"fquery": { | |
"query": { | |
"filtered": { | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"query_string": { | |
"query": "*" | |
} | |
} | |
] | |
} | |
}, | |
"filter": { | |
"bool": { | |
"must": [ | |
{ | |
"match_all": {} | |
}, | |
{ | |
"bool": { | |
"must": [ | |
{ | |
"match_all": {} | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"size": 0 | |
}' |
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
#!/usr/bin/ruby | |
# this script generates 12 terms, each with i*10 occurences | |
# eg, term12 appears 120 times, term8 appears 80 times | |
# It stores them in an index called 'terms' | |
require 'rubygems' | |
require 'tire' | |
index = "terms" | |
result = [] | |
i = 0 | |
12.times do | |
i += 1 | |
k = i*10; | |
k.times do | |
event = { | |
:term => "term#{i}", | |
:type => 'term', | |
} | |
result.push(event) | |
end | |
end | |
puts result | |
Tire.index index do | |
import result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yay Ruby!!