Boost field does not work


(Felix Xu) #1

Hi Guys,
I have two types in a index, one is used for indexing topics and another
one is used for indexing comments.
Here is the sample mapping:

Topic:

curl -XPUT http://localhost:9200/bbs/topic/_mapping -d'
{
"topic": {
"_timestamp": {
"enabled": true
},
"properties": {
"title": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 8
},
"content": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 4
}
}
}

Comment:

curl -XPUT http://localhost:9200/bbs/comment/_mapping -d'
{
"comment": {
"_timestamp": {
"enabled": true
},
"properties": {
"title": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 0
},
"content": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 4
}
}
}

I want to search theses two types(title,content of Topic and only content
of Comment) at the same time, however, I do not want to match the "title"
field of comments, since the title is the same with its corresponding
topic, matching the title field of a comment does not make any sense.
I have tried to set the boost value of Comment's title field to zero but it
seems does not work..
I think a simple solution is to set the "title" of Comment with
"not_analyzed", but I also want to highlight the matching words in the
title, so it's better to also index the title field but let it have little
effects on scoring..
Could someone please give me some hints? Thanks!

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/4dac461c-03ab-4014-ab27-53b50b01e8b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Ivan Brusic) #2

How do you know that the search is not working? Can you post an example
query and perhaps an example explanation?

If you are searching against the all field, you can set include_in_all to
false for that field. You are better off not searching a field instead of
trying to set a boost.

Cheers,

Ivan

On Mon, Jun 16, 2014 at 9:35 PM, Felix Xu ygnhzeus@gmail.com wrote:

Hi Guys,
I have two types in a index, one is used for indexing topics and another
one is used for indexing comments.
Here is the sample mapping:

Topic:

curl -XPUT http://localhost:9200/bbs/topic/_mapping -d'
{
"topic": {
"_timestamp": {
"enabled": true
},
"properties": {
"title": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 8
},
"content": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 4
}
}
}

Comment:

curl -XPUT http://localhost:9200/bbs/comment/_mapping -d'
{
"comment": {
"_timestamp": {
"enabled": true
},
"properties": {
"title": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 0
},
"content": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": true,
"boost": 4
}
}
}

I want to search theses two types(title,content of Topic and only content
of Comment) at the same time, however, I do not want to match the "title"
field of comments, since the title is the same with its corresponding
topic, matching the title field of a comment does not make any sense.
I have tried to set the boost value of Comment's title field to zero but
it seems does not work..
I think a simple solution is to set the "title" of Comment with
"not_analyzed", but I also want to highlight the matching words in the
title, so it's better to also index the title field but let it have little
effects on scoring..
Could someone please give me some hints? Thanks!

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/4dac461c-03ab-4014-ab27-53b50b01e8b5%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/4dac461c-03ab-4014-ab27-53b50b01e8b5%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQC0qnQn5oQKJoWJ1g5F8FR2KRjOOQJ9tx8GLcLyuWp-Kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3