Re: How to Boost

2015-05-01 Thread GWired
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^20\",\"Id^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 
>> ,
>>  
>> or you could use a multi-match query 
>> 
>>  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
>>> }
>>> }
>>> }
>>> }
>>> }
>>>
>>> Elasticsear

Re: How to Boost

2015-04-30 Thread GWired
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^20\",\"Id^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 
> ,
>  
> or you could use a multi-match query 
> 
>  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 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 

Re: Need suggestion: How to boost specific documents for a given search term

2015-04-29 Thread Xudong You
Any one has good suggestion?

On Tuesday, April 28, 2015 at 11:01:40 PM UTC+8, Xudong You wrote:
>
> Hi ES experts, 
>
> I need your help on index design for a real scenario. It might be a long 
> question, let me try explain it as concise as possible.
>
> We are building a search engine to provide site search for our customers, 
> the document in index could be something like this:
>
> { "Path":"http://www.foo.com/doc/abc/1";, "Title":"Title 1", 
> "Description":"The description of doc 1", ... }
> { "Path":"http://www.foo.com/doc/abc/2";, "Title":"Title 2", 
> "Description":"The description of doc 2", ... }
> { "Path":"http://www.foo.com/doc/abc/3";, "Title":"Title 3", 
> "Description":"The description of doc 3", ... }
> ...
>
> For each query, the returned hit documents are by default sorted by 
> relevance, but our customer also wants to *boost some specific documents 
> for some keywords,*
> They will give us the following like boosting configuration XML:
>
> 
> 
> http://www.foo.com/doc/abc/1
> 
> 
> http://www.foo.com/doc/abc/2
> http://www.foo.com/doc/abc/1
> 
> 
> http://www.foo.com/doc/abc/3
> http://www.foo.com/doc/abc/2
> http://www.foo.com/doc/abc/1
> 
> 
>
> That mean, if user search “keyword1", the top 1 hit document should be the 
> document whose Path field value is "http://www.foo.com/doc/abc/1";, 
> regardless the relevance score of that document. Similarly, if search 
> "keyword3", the top 3 hit documents should be "
> http://www.foo.com/doc/abc/3";, "http://www.foo.com/doc/abc/2"; and "
> http://www.foo.com/doc/abc/1"; respectively.
>
> To satisfy this special requirement, my design is, firstly invert the 
> original boosting XML to following format:
> 
> http://www.foo.com/doc/abc/1”>
> 
>
>
>
> 
> 
> http://www.foo.com/doc/abc/2”>
> 
>
>
> 
>  
> http://www.foo.com/doc/abc/3”>
> 
>
> 
> 
> 
>
> Then add a nested field "Boost", which contains a list of keyword/rank 
> field, to the document as following example:
> {
> "Boost": [ 
>{ "keyword":"keyword1", "rank": 1},
>{ "keyword":"keyword2", "rank": 9900},
>{ "keyword":"keyword3", "rank": 9800}
> ] 
> "Path":"http://www.foo.com/doc/abc/1";, 
> "Title":"Title 1", 
> "Description":"The description of doc 1",
>  ...
>  }
>
> {
> "Boost": [ 
>{ "keyword":"keyword2", "rank": 1},
>{ "keyword":"keyword3", "rank": 9900}
> ] 
> "Path":"http://www.foo.com/doc/abc/2";, 
> "Title":"Title 2", 
> "Description":"The description of doc 2",
>  ...
>  }
>
> {
> "Boost": [ 
>{ "keyword":"keyword3", "rank": 1}
> ] 
> "Path":"http://www.foo.com/doc/abc/3";, 
> "Title":"Title 3", 
> "Description":"The description of doc 3",
>  ...
>  }
>
> Then in query time, use nested query to get the rank value of each matched 
> document for a given search keyword, and use the score script to adjust the 
> relevance score by the rank value. Since the rank value from boosting XML 
> is much larger than normal relevance score ( generally less than 5), the 
> adjusted score of the documents which configured in boosting XML for given 
> keyword should be top scores.
>
> Does this design work well? Any suggestions to better design?
>
> Thanks in advance!
>

-- 
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/22af3d13-4d44-4550-9396-96d2974634ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Boost

2015-04-29 Thread Joel Potischman
You could use a boosting query 
,
 
or you could use a multi-match query 

 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 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.


How to Boost

2015-04-28 Thread GWired
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 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/ccffa252-30c4-444d-9bbb-cd28a1acec50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Need suggestion: How to boost specific documents for a given search term

2015-04-28 Thread Xudong You
Hi ES experts, 

I need your help on index design for a real scenario. It might be a long 
question, let me try explain it as concise as possible.

We are building a search engine to provide site search for our customers, 
the document in index could be something like this:

{ "Path":"http://www.foo.com/doc/abc/1";, "Title":"Title 1", 
"Description":"The description of doc 1", ... }
{ "Path":"http://www.foo.com/doc/abc/2";, "Title":"Title 2", 
"Description":"The description of doc 2", ... }
{ "Path":"http://www.foo.com/doc/abc/3";, "Title":"Title 3", 
"Description":"The description of doc 3", ... }
...

For each query, the returned hit documents are by default sorted by 
relevance, but our customer also wants to *boost some specific documents 
for some keywords,*
They will give us the following like boosting configuration XML:



http://www.foo.com/doc/abc/1


http://www.foo.com/doc/abc/2
http://www.foo.com/doc/abc/1


http://www.foo.com/doc/abc/3
http://www.foo.com/doc/abc/2
http://www.foo.com/doc/abc/1



That mean, if user search “keyword1", the top 1 hit document should be the 
document whose Path field value is "http://www.foo.com/doc/abc/1";, 
regardless the relevance score of that document. Similarly, if search 
"keyword3", the top 3 hit documents should be 
"http://www.foo.com/doc/abc/3";, "http://www.foo.com/doc/abc/2"; and 
"http://www.foo.com/doc/abc/1"; respectively.

To satisfy this special requirement, my design is, firstly invert the 
original boosting XML to following format:

http://www.foo.com/doc/abc/1”>

   
   
   


http://www.foo.com/doc/abc/2”>

   
   

 
http://www.foo.com/doc/abc/3”>

   




Then add a nested field "Boost", which contains a list of keyword/rank 
field, to the document as following example:
{
"Boost": [ 
   { "keyword":"keyword1", "rank": 1},
   { "keyword":"keyword2", "rank": 9900},
   { "keyword":"keyword3", "rank": 9800}
] 
"Path":"http://www.foo.com/doc/abc/1";, 
"Title":"Title 1", 
"Description":"The description of doc 1",
 ...
 }

{
"Boost": [ 
   { "keyword":"keyword2", "rank": 1},
   { "keyword":"keyword3", "rank": 9900}
] 
"Path":"http://www.foo.com/doc/abc/2";, 
"Title":"Title 2", 
"Description":"The description of doc 2",
 ...
 }

{
"Boost": [ 
   { "keyword":"keyword3", "rank": 1}
] 
"Path":"http://www.foo.com/doc/abc/3";, 
"Title":"Title 3", 
"Description":"The description of doc 3",
 ...
 }

Then in query time, use nested query to get the rank value of each matched 
document for a given search keyword, and use the score script to adjust the 
relevance score by the rank value. Since the rank value from boosting XML 
is much larger than normal relevance score ( generally less than 5), the 
adjusted score of the documents which configured in boosting XML for given 
keyword should be top scores.

Does this design work well? Any suggestions to better design?

Thanks in advance!

-- 
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/3eb89d0f-b9a4-4d84-bc04-e0c764b9e314%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Boost the document with following conditions

2013-12-30 Thread David Pilato
You can try playing with boost but in your case function score feature could be 
more appropriate.

HTH

--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 30 déc. 2013 à 06:14, Jayesh Bhoyar  a écrit :

> Hi Team,
>  
> Any update on this query?
>  
> Regards,
> Jayesh Bhoyar
>  
>  
> 
> On Friday, December 27, 2013 3:29:32 PM UTC+5:30, Jayesh Bhoyar wrote:
>> HI,
>> 
>> I want to boost the documents based on following conditions:
>> So could you please help me out in the query syntax for each of the 
>> following.
>> I am using ES 0.90.7
>> 
>> 1) Higher boost if Search keyword appears at the start of title.
>> Example: If I am searching for "Rum Cake"
>> Then Title1 should get higher boosting than Title2
>> 
>> Title1: "Rum Cakes are always good in Taste"
>> Title2: "I Love Rum Cakes"
>> 
>> -
>> 2) Higher weightage to "frequently asked questions" word in the title and
>> Higher weightage to "technical Specifications" word in the title
>> 
>> -
>> 3) 
>> If the search keyword is the complete title itself than it has higher 
>> priority than the title which has the search keyword along with some of the 
>> other words
>> Example: If I am searching for "Rum Cake"
>> Then Title1 should get higher boosting than Title2
>> 
>> Title1: "Rum Cakes"
>> Title2: "I Love Rum Cakes"
>> 
>> Please let me know if the above 3 rules can be configured in elasticsearch 
>> or not?
>> If Yes, Could you please explain them in form of queries.
>> 
>> Regards,
>> Jayesh Bhoyar
> 
> -- 
> 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/78296a01-c04e-4822-a346-5712f98cb9db%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/B5C62F3C-ED2E-48A5-8B8F-14D20A407AED%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to Boost the document with following conditions

2013-12-29 Thread Jayesh Bhoyar
Hi Team,
 
Any update on this query?
 
Regards,
Jayesh Bhoyar
 
 

On Friday, December 27, 2013 3:29:32 PM UTC+5:30, Jayesh Bhoyar wrote:

> HI,
>
> I want to boost the documents based on following conditions:
> So could you please help me out in the query syntax for each of the 
> following.
> I am using ES 0.90.7
>
> 1) Higher boost if Search keyword appears at the start of title.
> Example: If I am searching for "Rum Cake"
> Then Title1 should get higher boosting than Title2
>
> Title1: "Rum Cakes are always good in Taste"
> Title2: "I Love Rum Cakes"
>
> -
> 2) Higher weightage to "frequently asked questions" word in the title and
> Higher weightage to "technical Specifications" word in the title
>
> -
> 3) 
> If the search keyword is the complete title itself than it has higher 
> priority than the title which has the search keyword along with some of the 
> other words
> Example: If I am searching for "Rum Cake"
> Then Title1 should get higher boosting than Title2
>
> Title1: "Rum Cakes"
> Title2: "I Love Rum Cakes"
>
> Please let me know if the above 3 rules can be configured in elasticsearch 
> or not?
> If Yes, Could you please explain them in form of queries.
>
> Regards,
> Jayesh Bhoyar
>
>

-- 
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/78296a01-c04e-4822-a346-5712f98cb9db%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


How to Boost the document with following conditions

2013-12-27 Thread Jayesh Bhoyar
HI,

I want to boost the documents based on following conditions:
So could you please help me out in the query syntax for each of the 
following.
I am using ES 0.90.7

1) Higher boost if Search keyword appears at the start of title.
Example: If I am searching for "Rum Cake"
Then Title1 should get higher boosting than Title2

Title1: "Rum Cakes are always good in Taste"
Title2: "I Love Rum Cakes"

-
2) Higher weightage to "frequently asked questions" word in the title and
Higher weightage to "technical Specifications" word in the title

-
3) 
If the search keyword is the complete title itself than it has higher 
priority than the title which has the search keyword along with some of the 
other words
Example: If I am searching for "Rum Cake"
Then Title1 should get higher boosting than Title2

Title1: "Rum Cakes"
Title2: "I Love Rum Cakes"

Please let me know if the above 3 rules can be configured in elasticsearch 
or not?
If Yes, Could you please explain them in form of queries.

Regards,
Jayesh Bhoyar

-- 
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/0481d882-1fc8-4c84-9660-aee0f8f4007a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.