You could use a boosting query <http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html>, or you could use a multi-match query <http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html> and add a boost directly to the name and id fields. Something like:
{ "multi_match": { "fields": [ "name^2", "id^2", "_all" ], "query": keyword, "type": "best_fields" } } That tells Elasticsearch to search all fields, but to additionally search name and id and double their score if they match (that's the "^2" part). the "best_fields" type will use the best score from the name, id, and _all searches. You might want most_fields to rank records that contain your query terms in name *and* id *and* other fields even higher. Note that my snippet is using the Query DSL. The syntax for the client you're using will probably be slightly different but that's the general idea. Also note that I've been using Elasticsearch less than a year though so there may be better approaches, but that's where I'd start. -joel On Tuesday, April 28, 2015 at 4:42:56 PM UTC-4, GWired wrote: > > I am attempting to boost values for queries. > > I'm searching across all fields and tables and returning 25 results for > each type. > > This is working fine however I need to Boost if the field name Name or the > Field Name ID have the value in it. > > I'm using ElasticSearchClient and sending this search. > > search = new > { > > query = new > { > query_string = new > { > query = keyword, > default_field = "_all" > } > }, > from = 0, > size = limitAllTypes, > aggs = new > { > top_types = new > { > terms = new > { > field = "_type" > }, > aggs = new > { > top_type_hits = new > { > top_hits = new > { > size = limitPerType > } > } > } > } > } > > ElasticsearchResponse<DynamicDictionary> searchResponse = > client.Search("jdbc", search, null); > > How do i tell this to boost the name and id fields over all other fields. > > If I'm searching for "My Searched Company" and that is in the Name field I > want it at the top of the list. vs in notes, addresses or whatever other > columns etc. > > > -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ff22e57d-cc39-43d9-b403-025e0f345cd1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.