search-collapse #6
|
@ -6,11 +6,11 @@ func TestFilterAggs(t *testing.T) {
|
||||||
runMapTests(t, []mapTest{
|
runMapTests(t, []mapTest{
|
||||||
{
|
{
|
||||||
"filter agg: simple",
|
"filter agg: simple",
|
||||||
FilterAgg("filtered", Term("type","t-shirt")),
|
FilterAgg("filtered", Term("type", "t-shirt")),
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"filter": map[string]interface{}{
|
"filter": map[string]interface{}{
|
||||||
"term": map[string]interface{} {
|
"term": map[string]interface{}{
|
||||||
"type": map[string]interface{} {
|
"type": map[string]interface{}{
|
||||||
"value": "t-shirt",
|
"value": "t-shirt",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -19,18 +19,18 @@ func TestFilterAggs(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filter agg: with aggs",
|
"filter agg: with aggs",
|
||||||
FilterAgg("filtered", Term("type","t-shirt")).
|
FilterAgg("filtered", Term("type", "t-shirt")).
|
||||||
Aggs(Avg("avg_price","price")),
|
Aggs(Avg("avg_price", "price")),
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"filter": map[string]interface{}{
|
"filter": map[string]interface{}{
|
||||||
"term": map[string]interface{} {
|
"term": map[string]interface{}{
|
||||||
"type": map[string]interface{} {
|
"type": map[string]interface{}{
|
||||||
"value": "t-shirt",
|
"value": "t-shirt",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"aggs": map[string]interface{} {
|
"aggs": map[string]interface{}{
|
||||||
"avg_price": map[string]interface{} {
|
"avg_price": map[string]interface{}{
|
||||||
"avg": map[string]interface{}{
|
"avg": map[string]interface{}{
|
||||||
"field": "price",
|
"field": "price",
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,14 +16,14 @@ func TestNestedAggs(t *testing.T) {
|
||||||
{
|
{
|
||||||
"nested agg: with aggs",
|
"nested agg: with aggs",
|
||||||
NestedAgg("more_nested", "authors").
|
NestedAgg("more_nested", "authors").
|
||||||
Aggs(TermsAgg("authors","name")),
|
Aggs(TermsAgg("authors", "name")),
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"nested": map[string]interface{}{
|
"nested": map[string]interface{}{
|
||||||
"path": "authors",
|
"path": "authors",
|
||||||
},
|
},
|
||||||
"aggs": map[string]interface{} {
|
"aggs": map[string]interface{}{
|
||||||
"authors": map[string]interface{} {
|
"authors": map[string]interface{}{
|
||||||
"terms": map[string]interface{} {
|
"terms": map[string]interface{}{
|
||||||
"field": "name",
|
"field": "name",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,13 +64,13 @@ func newHighlight() *QueryHighlight {
|
||||||
|
|
||||||
// PreTags sets the highlight query's pre_tags ignore unmapped field
|
// PreTags sets the highlight query's pre_tags ignore unmapped field
|
||||||
func (q *QueryHighlight) PreTags(s ...string) *QueryHighlight {
|
func (q *QueryHighlight) PreTags(s ...string) *QueryHighlight {
|
||||||
q.params.PreTags = append(q.params.PreTags,s...)
|
q.params.PreTags = append(q.params.PreTags, s...)
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostTags sets the highlight query's post_tags ignore unmapped field
|
// PostTags sets the highlight query's post_tags ignore unmapped field
|
||||||
func (q *QueryHighlight) PostTags(s ...string) *QueryHighlight {
|
func (q *QueryHighlight) PostTags(s ...string) *QueryHighlight {
|
||||||
q.params.PostTags = append(q.params.PostTags,s...)
|
q.params.PostTags = append(q.params.PostTags, s...)
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ func (q *QueryHighlight) HighlightQuery(b Mappable) *QueryHighlight {
|
||||||
|
|
||||||
// MatchedFields sets the highlight query's matched_fields ignore unmapped field
|
// MatchedFields sets the highlight query's matched_fields ignore unmapped field
|
||||||
func (q *QueryHighlight) MatchedFields(s ...string) *QueryHighlight {
|
func (q *QueryHighlight) MatchedFields(s ...string) *QueryHighlight {
|
||||||
q.params.MatchedFields = append(q.params.MatchedFields,s...)
|
q.params.MatchedFields = append(q.params.MatchedFields, s...)
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ func TestHighlight(t *testing.T) {
|
||||||
"simple highlight",
|
"simple highlight",
|
||||||
Highlight().Field("content"),
|
Highlight().Field("content"),
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"fields": map[string]interface{} {
|
"fields": map[string]interface{}{
|
||||||
"content": map[string]interface{}{},
|
"content": map[string]interface{}{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -18,8 +18,8 @@ func TestHighlight(t *testing.T) {
|
||||||
{
|
{
|
||||||
"highlight all params",
|
"highlight all params",
|
||||||
Highlight().
|
Highlight().
|
||||||
PreTags("<pre>","<code>").
|
PreTags("<pre>", "<code>").
|
||||||
PostTags("</code>","</pre>").
|
PostTags("</code>", "</pre>").
|
||||||
Field("content",
|
Field("content",
|
||||||
Highlight().
|
Highlight().
|
||||||
BoundaryChars(".;,")).
|
BoundaryChars(".;,")).
|
||||||
|
@ -41,15 +41,15 @@ func TestHighlight(t *testing.T) {
|
||||||
Query("some guy").
|
Query("some guy").
|
||||||
Analyzer("analyzer?").
|
Analyzer("analyzer?").
|
||||||
Fuzziness("fuzz"))).
|
Fuzziness("fuzz"))).
|
||||||
MatchedFields("title","body").
|
MatchedFields("title", "body").
|
||||||
NoMatchSize(64).
|
NoMatchSize(64).
|
||||||
Order(OrderScore).
|
Order(OrderScore).
|
||||||
PhraseLimit(512).
|
PhraseLimit(512).
|
||||||
RequireFieldMatch(false).
|
RequireFieldMatch(false).
|
||||||
TagsSchema(TagsSchemaStyled),
|
TagsSchema(TagsSchemaStyled),
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"pre_tags": []string{"<pre>","<code>"},
|
"pre_tags": []string{"<pre>", "<code>"},
|
||||||
"post_tags": []string{"</code>","</pre>"},
|
"post_tags": []string{"</code>", "</pre>"},
|
||||||
"fragment_size": 150,
|
"fragment_size": 150,
|
||||||
"number_of_fragments": 4,
|
"number_of_fragments": 4,
|
||||||
"type": "plain",
|
"type": "plain",
|
||||||
|
@ -61,7 +61,7 @@ func TestHighlight(t *testing.T) {
|
||||||
"force_source": true,
|
"force_source": true,
|
||||||
"fragment_offset": 6,
|
"fragment_offset": 6,
|
||||||
"fragmenter": "simple",
|
"fragmenter": "simple",
|
||||||
"matched_fields": []string{"title","body"},
|
"matched_fields": []string{"title", "body"},
|
||||||
"no_match_size": 64,
|
"no_match_size": 64,
|
||||||
"order": "score",
|
"order": "score",
|
||||||
"phrase_limit": 512,
|
"phrase_limit": 512,
|
||||||
|
@ -72,12 +72,12 @@ func TestHighlight(t *testing.T) {
|
||||||
"boundary_chars": ".;,",
|
"boundary_chars": ".;,",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"query": map[string]interface{} {
|
"query": map[string]interface{}{
|
||||||
"bool": map[string]interface{} {
|
"bool": map[string]interface{}{
|
||||||
"must": []map[string]interface{} {
|
"must": []map[string]interface{}{
|
||||||
{
|
{
|
||||||
"match": map[string]interface{} {
|
"match": map[string]interface{}{
|
||||||
"author": map[string]interface{} {
|
"author": map[string]interface{}{
|
||||||
"analyzer": "analyzer?",
|
"analyzer": "analyzer?",
|
||||||
"fuzziness": "fuzz",
|
"fuzziness": "fuzz",
|
||||||
"query": "some guy",
|
"query": "some guy",
|
||||||
|
|
|
@ -8,7 +8,7 @@ func TestMultiMatch(t *testing.T) {
|
||||||
runMapTests(t, []mapTest{
|
runMapTests(t, []mapTest{
|
||||||
{
|
{
|
||||||
"simple multi_match",
|
"simple multi_match",
|
||||||
MultiMatch("value1","value2").Fields("title"),
|
MultiMatch("value1", "value2").Fields("title"),
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"multi_match": map[string]interface{}{
|
"multi_match": map[string]interface{}{
|
||||||
"fields": []string{"title"},
|
"fields": []string{"title"},
|
||||||
|
@ -21,7 +21,7 @@ func TestMultiMatch(t *testing.T) {
|
||||||
MultiMatch("original").
|
MultiMatch("original").
|
||||||
Query("test").
|
Query("test").
|
||||||
Analyzer("stop").
|
Analyzer("stop").
|
||||||
Fields("title","body").
|
Fields("title", "body").
|
||||||
AutoGenerateSynonymsPhraseQuery(true).
|
AutoGenerateSynonymsPhraseQuery(true).
|
||||||
Fuzziness("AUTO").
|
Fuzziness("AUTO").
|
||||||
MaxExpansions(16).
|
MaxExpansions(16).
|
||||||
|
@ -54,7 +54,7 @@ func TestMultiMatch(t *testing.T) {
|
||||||
"zero_terms_query": "all",
|
"zero_terms_query": "all",
|
||||||
"slop": 2,
|
"slop": 2,
|
||||||
"query": "test",
|
"query": "test",
|
||||||
"fields": []string{"title","body"},
|
"fields": []string{"title", "body"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue