[elasticsearch] custom similarity plugin [펌]
Elastic/Elasticsearch 2013. 7. 16. 20:21https://github.com/elasticsearch/elasticsearch/issues/2707
https://github.com/tlrx/elasticsearch-custom-similarity-provider
https://github.com/lukapor/customsimilarity
위 내용을 보면 기본적으로 루씬에서 score 계산에 사용하는 함수들을 @override 해야 합니다.
결국, 문서 및 서비스 특성을 반영한 별도의 ranking algorithm 을 만들어서 적용을 해야 한다는 내용입니다.
package org.elasticsearch.bcsocial.plugin.similarity;import org.apache.lucene.index.FieldInvertState;import org.apache.lucene.search.similarities.Similarity;import org.apache.lucene.search.similarities.TFIDFSimilarity;import org.apache.lucene.search.similarities.DefaultSimilarity;public class BcsocialSimilarity extends DefaultSimilarity {public BcsocialSimilarity() {}@Overridepublic float lengthNorm(FieldInvertState state) {return 1.0f;}@Overridepublic float coord(int overlap, int maxOverlap) {return 1.0f;}@Overridepublic float queryNorm(float sumOfSquaredWeights) {return 1.0f;}@Overridepublic float tf(float freq) {return 1.0f;}@Overridepublic float idf(long docFreq, long numDocs) {return 1.0f;}@Overridepublic String toString() {return "BcsocialSimilarity";}}