Can I use 'indexOf(keyword)' like Java when I query by Custom Score?

Hello all.

I have a question.
For example, there are documents as following.

  1. Love is blue.
  2. Blue is love.
  3. Red is not love.

In this case if I apply indexOf('Love'), result is as following.

  1. Love is blue = index 0
  2. Love is blue = index 8
  3. Love is blue = index 12

Finally, I would like to compute score like following pseudo syntax.

script : "_score * sentence.indexOf(keyword)"

In ElasticSearch, is this possible?
Please give me some advice.

Thanks for reading.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hello.

I have resolved this issue.
Following is a example to resolve my problem.

{"query":{"custom_score":{"query":{"query_string":{"query":"title:"Love""}},"script":"_source.weight

  • new String(_source.title).indexOf("Love") * 0.00001"}}}

2013년 11월 21일 목요일 오후 5시 11분 53초 UTC+9, Min Cha 님의 말:

Hello all.

I have a question.
For example, there are documents as following.

  1. Love is blue.
  2. Blue is love.
  3. Red is not love.

In this case if I apply indexOf('Love'), result is as following.

  1. Love is blue = index 0
  2. Love is blue = index 8
  3. Love is blue = index 12

Finally, I would like to compute score like following pseudo syntax.

script : "_score * sentence.indexOf(keyword)"

In Elasticsearch, is this possible?
Please give me some advice.

Thanks for reading.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.