Re: How to Boost
I got it: To add an array of var to an anonymous type add them like this. var field1 = new {field=Name^20}; var field2 = new {field = _all}; var field3 = new {field = Id^20}; var myfields = new [] {field1,field2}; This is slick now it puts the brackets in and there is no escaping :-) On Thursday, April 30, 2015 at 9:01:27 PM UTC-4, GWired wrote: I was able to get this to work in ES using head and got back what i needed. However translating to ElasticSearch.net has been an issue. I have an anonymous type doing a match all query and this works fine and dandy. I am trying to do the multi_match as above but it isn't returning any results. I'm not sure var myfields = [\Name#94;20\,\Id#94;20\,\_all\]; - this gets no results var myfields = [\Name^20\,\Id^20\,\_all\]; - this crashes with all kinds of errors How do you do these bracketed values? var search = new { query = new { multi_match = new { fields = myfields, query = keyword, type = best_fields, use_dis_max= true } }, from = 0, size = limitAllTypes, aggs = new { top_types = new { terms = new { field = _type }, aggs = new { top_type_hits = new { top_hits = new { size = limitPerType } } } } } }; On Wednesday, April 29, 2015 at 12:06:47 PM UTC-4, Joel Potischman wrote: 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 } } } } } ElasticsearchResponseDynamicDictionary 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
Re: How to Boost
I was able to get this to work in ES using head and got back what i needed. However translating to ElasticSearch.net has been an issue. I have an anonymous type doing a match all query and this works fine and dandy. I am trying to do the multi_match as above but it isn't returning any results. I'm not sure var myfields = [\Name#94;20\,\Id#94;20\,\_all\]; - this gets no results var myfields = [\Name^20\,\Id^20\,\_all\]; - this crashes with all kinds of errors How do you do these bracketed values? var search = new { query = new { multi_match = new { fields = myfields, query = keyword, type = best_fields, use_dis_max= true } }, from = 0, size = limitAllTypes, aggs = new { top_types = new { terms = new { field = _type }, aggs = new { top_type_hits = new { top_hits = new { size = limitPerType } } } } } }; On Wednesday, April 29, 2015 at 12:06:47 PM UTC-4, Joel Potischman wrote: 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 } } } } } ElasticsearchResponseDynamicDictionary 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/c331b066-75e8-491e-8ffc-e4f8539f100e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to Boost
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 } } } } } ElasticsearchResponseDynamicDictionary 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.