// Creates a JSON string, ready to pass to an ES Query.
// This is currently non-functional. The query construction
// process must be carefully refactored to produce better
// search results.
Creates a JSON string, ready to pass to an ES Query.
This is currently non-functional. The query construction
process must be carefully refactored to produce better
search results.
// Creates a JSON string ready to pass to an ES Query . // This is currently non - functional . The query construction // process must be carefully refactored to produce better // search results .
func createQueryJSON(query ...string) (bytes.Buffer, error) {
	var buf bytes.Buffer
	esQuery := map[string]interface{}{
	  	"query": map[string]interface{}{
			"multi_match": map[string]interface{}{
				"query": 	html.UnescapeString(query[0]),
				"type": 	"best_fields",
		  		"fields": 	[]string{"name", "tags"},
			},
		  },
		  "size": 	25,
	}
	if err := json.NewEncoder(&buf).Encode(esQuery); err != nil {
		return bytes.Buffer{}, fmt.Errorf("Error encoding query: %s", err)
	}
	return buf, nil
}
func createQueryJSON ( query ... string ) ( bytes . Buffer , error ) { var buf bytes . Buffer esQuery := map [ string ] interface { } { " " : map [ string ] interface { } { " " : map [ string ] interface { } { " " : html . UnescapeString ( query [ 0 ] ) , " " : " " , " " : [ ] string { " " , " " } , } , } , " " : 25 , } if err := json . NewEncoder ( & buf ) . Encode ( esQuery ) ; err != nil { return bytes . Buffer { } , fmt . Errorf ( " " , err ) } return buf , nil }
Creates a JSON string, ready to pass to an ES Query.
Creates a JSON string ready to pass to an ES Query .
// Construct the request body. // This runs the query through a search in the name and tags fields.