boost support for match query added
This commit is contained in:
		
							parent
							
								
									49a92fc25e
								
							
						
					
					
						commit
						1bb7b17d84
					
				@ -71,6 +71,7 @@ type matchParams struct {
 | 
				
			|||||||
	MinMatch     string        `structs:"minimum_should_match,omitempty"`
 | 
						MinMatch     string        `structs:"minimum_should_match,omitempty"`
 | 
				
			||||||
	ZeroTerms    ZeroTerms     `structs:"zero_terms_query,string,omitempty"`
 | 
						ZeroTerms    ZeroTerms     `structs:"zero_terms_query,string,omitempty"`
 | 
				
			||||||
	Slp          uint16        `structs:"slop,omitempty"` // only relevant for match_phrase query
 | 
						Slp          uint16        `structs:"slop,omitempty"` // only relevant for match_phrase query
 | 
				
			||||||
 | 
						Boost        float32       `structs:"boost,omitempty"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Match creates a new query of type "match" with the provided field name.
 | 
					// Match creates a new query of type "match" with the provided field name.
 | 
				
			||||||
@ -202,6 +203,12 @@ func (q *MatchQuery) ZeroTermsQuery(s ZeroTerms) *MatchQuery {
 | 
				
			|||||||
	return q
 | 
						return q
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Boost sets the boost value of the query.
 | 
				
			||||||
 | 
					func (q *MatchQuery) Boost(b float32) *MatchQuery {
 | 
				
			||||||
 | 
						q.params.Boost = b
 | 
				
			||||||
 | 
						return q
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MatchOperator is an enumeration type representing supported values for a
 | 
					// MatchOperator is an enumeration type representing supported values for a
 | 
				
			||||||
// match query's "operator" parameter.
 | 
					// match query's "operator" parameter.
 | 
				
			||||||
type MatchOperator uint8
 | 
					type MatchOperator uint8
 | 
				
			||||||
 | 
				
			|||||||
@ -17,6 +17,18 @@ func TestMatch(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"simple match with boost",
 | 
				
			||||||
 | 
								Match("title", "sample text").Boost(50),
 | 
				
			||||||
 | 
								map[string]interface{}{
 | 
				
			||||||
 | 
									"match": map[string]interface{}{
 | 
				
			||||||
 | 
										"title": map[string]interface{}{
 | 
				
			||||||
 | 
											"query": "sample text",
 | 
				
			||||||
 | 
											"boost": 50,
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"match with more params",
 | 
								"match with more params",
 | 
				
			||||||
			Match("issue_number").Query(16).Transpositions(false).MaxExpansions(32).Operator(OperatorAnd),
 | 
								Match("issue_number").Query(16).Transpositions(false).MaxExpansions(32).Operator(OperatorAnd),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user