search-collapse #6

Merged
maxim.yanchuk merged 17 commits from search-collapse into master 2023-11-01 21:11:52 +00:00
8 changed files with 131 additions and 131 deletions
Showing only changes of commit 37dac903cc - Show all commits

View File

@ -6,11 +6,11 @@ func TestFilterAggs(t *testing.T) {
runMapTests(t, []mapTest{
{
"filter agg: simple",
FilterAgg("filtered", Term("type","t-shirt")),
FilterAgg("filtered", Term("type", "t-shirt")),
map[string]interface{}{
"filter": map[string]interface{}{
"term": map[string]interface{} {
"type": map[string]interface{} {
"term": map[string]interface{}{
"type": map[string]interface{}{
"value": "t-shirt",
},
},
@ -19,18 +19,18 @@ func TestFilterAggs(t *testing.T) {
},
{
"filter agg: with aggs",
FilterAgg("filtered", Term("type","t-shirt")).
Aggs(Avg("avg_price","price")),
FilterAgg("filtered", Term("type", "t-shirt")).
Aggs(Avg("avg_price", "price")),
map[string]interface{}{
"filter": map[string]interface{}{
"term": map[string]interface{} {
"type": map[string]interface{} {
"term": map[string]interface{}{
"type": map[string]interface{}{
"value": "t-shirt",
},
},
},
"aggs": map[string]interface{} {
"avg_price": map[string]interface{} {
"aggs": map[string]interface{}{
"avg_price": map[string]interface{}{
"avg": map[string]interface{}{
"field": "price",
},

View File

@ -16,14 +16,14 @@ func TestNestedAggs(t *testing.T) {
{
"nested agg: with aggs",
NestedAgg("more_nested", "authors").
Aggs(TermsAgg("authors","name")),
Aggs(TermsAgg("authors", "name")),
map[string]interface{}{
"nested": map[string]interface{}{
"path": "authors",
},
"aggs": map[string]interface{} {
"authors": map[string]interface{} {
"terms": map[string]interface{} {
"aggs": map[string]interface{}{
"authors": map[string]interface{}{
"terms": map[string]interface{}{
"field": "name",
},
},

View File

@ -64,13 +64,13 @@ func newHighlight() *QueryHighlight {
// PreTags sets the highlight query's pre_tags ignore unmapped field
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
}
// PostTags sets the highlight query's post_tags ignore unmapped field
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
}
@ -166,7 +166,7 @@ func (q *QueryHighlight) HighlightQuery(b Mappable) *QueryHighlight {
// MatchedFields sets the highlight query's matched_fields ignore unmapped field
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
}

View File

@ -10,7 +10,7 @@ func TestHighlight(t *testing.T) {
"simple highlight",
Highlight().Field("content"),
map[string]interface{}{
"fields": map[string]interface{} {
"fields": map[string]interface{}{
"content": map[string]interface{}{},
},
},
@ -18,8 +18,8 @@ func TestHighlight(t *testing.T) {
{
"highlight all params",
Highlight().
PreTags("<pre>","<code>").
PostTags("</code>","</pre>").
PreTags("<pre>", "<code>").
PostTags("</code>", "</pre>").
Field("content",
Highlight().
BoundaryChars(".;,")).
@ -41,15 +41,15 @@ func TestHighlight(t *testing.T) {
Query("some guy").
Analyzer("analyzer?").
Fuzziness("fuzz"))).
MatchedFields("title","body").
MatchedFields("title", "body").
NoMatchSize(64).
Order(OrderScore).
PhraseLimit(512).
RequireFieldMatch(false).
TagsSchema(TagsSchemaStyled),
map[string]interface{}{
"pre_tags": []string{"<pre>","<code>"},
"post_tags": []string{"</code>","</pre>"},
"pre_tags": []string{"<pre>", "<code>"},
"post_tags": []string{"</code>", "</pre>"},
"fragment_size": 150,
"number_of_fragments": 4,
"type": "plain",
@ -61,7 +61,7 @@ func TestHighlight(t *testing.T) {
"force_source": true,
"fragment_offset": 6,
"fragmenter": "simple",
"matched_fields": []string{"title","body"},
"matched_fields": []string{"title", "body"},
"no_match_size": 64,
"order": "score",
"phrase_limit": 512,
@ -72,12 +72,12 @@ func TestHighlight(t *testing.T) {
"boundary_chars": ".;,",
},
},
"query": map[string]interface{} {
"bool": map[string]interface{} {
"must": []map[string]interface{} {
"query": map[string]interface{}{
"bool": map[string]interface{}{
"must": []map[string]interface{}{
{
"match": map[string]interface{} {
"author": map[string]interface{} {
"match": map[string]interface{}{
"author": map[string]interface{}{
"analyzer": "analyzer?",
"fuzziness": "fuzz",
"query": "some guy",

View File

@ -8,7 +8,7 @@ func TestMultiMatch(t *testing.T) {
runMapTests(t, []mapTest{
{
"simple multi_match",
MultiMatch("value1","value2").Fields("title"),
MultiMatch("value1", "value2").Fields("title"),
map[string]interface{}{
"multi_match": map[string]interface{}{
"fields": []string{"title"},
@ -21,7 +21,7 @@ func TestMultiMatch(t *testing.T) {
MultiMatch("original").
Query("test").
Analyzer("stop").
Fields("title","body").
Fields("title", "body").
AutoGenerateSynonymsPhraseQuery(true).
Fuzziness("AUTO").
MaxExpansions(16).
@ -54,7 +54,7 @@ func TestMultiMatch(t *testing.T) {
"zero_terms_query": "all",
"slop": 2,
"query": "test",
"fields": []string{"title","body"},
"fields": []string{"title", "body"},
},
},
},