Hi,

I'm using a custom score query for fetching my results from elasticsearch. 
I used a popularity "po" field for modifying _script parameter but somehow 
it's not working. I used explain parameter to see how the score is getting 
caluclated but my problem is it doesn't seem to take po into consideration 
while calculating score. I have printed the score calculation for two docs. 
Both have same scores but po field is different for both. Can anyone tell 
me where am I going wrong ?

I'm using the following custom score query in my java code:-
        String script = "_score * (doc['po'].empty ? 1 : doc['po'].value == 
0.0 ? 1 : doc['po'].value)";
        QueryBuilder queryBuilder = QueryBuilders.customScoreQuery(
                                        QueryBuilders.queryString(query)
                                            .field("text",30)
                                            .field("ad")
                                            .field("st")
                                            .field("cn")
                                            .field("co")
                                            
.defaultOperator(Operator.AND)).script(script);


{category=Hotel, text=hotels in ranchi, count=45.0, 
_id=525472d7d4a769f431649936, location={lon=85.33333, lat=23.35},  po=8.8}
1195.7068 = custom score, product of:
  1195.7068 = script score function: composed of:
    239.14136 = sum of:
      215.63971 = max of:
        215.63971 = sum of:
          18.701233 = weight(text:ho in 170585) [PerFieldSimilarity], 
result of:
            18.701233 = score(doc=170585,freq=1.0 = termFreq=1.0
), product of:
              0.27964544 = queryWeight, product of:
                2.7864501 = idf(docFreq=960416, maxDocs=5731988)
                0.10035904 = queryNorm
              66.8748 = fieldWeight in 170585, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                2.7864501 = idf(docFreq=960416, maxDocs=5731988)
                24.0 = fieldNorm(doc=170585)
          22.496681 = weight(text:hot in 170585) [PerFieldSimilarity], 
result of:
            22.496681 = score(doc=170585,freq=1.0 = termFreq=1.0
), product of:
              0.30671278 = queryWeight, product of:
                3.056155 = idf(docFreq=733378, maxDocs=5731988)
                0.10035904 = queryNorm
              73.34772 = fieldWeight in 170585, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                3.056155 = idf(docFreq=733378, maxDocs=5731988)
                24.0 = fieldNorm(doc=170585)
          22.589373 = weight(text:hote in 170585) [PerFieldSimilarity], 
result of:
            22.589373 = score(doc=170585,freq=1.0 = termFreq=1.0
), product of:
              0.307344 = queryWeight, product of:
                3.0624444 = idf(docFreq=728780, maxDocs=5731988)
                0.10035904 = queryNorm
              73.498665 = fieldWeight in 170585, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                3.0624444 = idf(docFreq=728780, maxDocs=5731988)
                24.0 = fieldNorm(doc=170585)
          22.600088 = weight(text:hotel in 170585) [PerFieldSimilarity], 
result of:
            22.600088 = score(doc=170585,freq=1.0 = termFreq=1.0
), product of:
              0.30741686 = queryWeight, product of:
                3.0631707 = idf(docFreq=728251, maxDocs=5731988)
                0.10035904 = queryNorm
              73.5161 = fieldWeight in 170585, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                3.0631707 = idf(docFreq=728251, maxDocs=5731988)
                24.0 = fieldNorm(doc=170585)
          129.25233 = weight(text:hotels in 170585) [PerFieldSimilarity], 
result of:
            129.25233 = score(doc=170585,freq=1.0 = termFreq=1.0
), product of:
              0.73517686 = queryWeight, product of:
                7.3254676 = idf(docFreq=10260, maxDocs=5731988)
                0.10035904 = queryNorm
              175.81122 = fieldWeight in 170585, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                7.3254676 = idf(docFreq=10260, maxDocs=5731988)
                24.0 = fieldNorm(doc=170585)
      23.50164 = max of:
        23.50164 = weight(text:in^30.0 in 170585) [PerFieldSimilarity], 
result of:
          23.50164 = score(doc=170585,freq=1.0 = termFreq=1.0
), product of:
            0.31348857 = queryWeight, product of:
              30.0 = boost
              3.1236706 = idf(docFreq=685498, maxDocs=5731988)
              0.0033453014 = queryNorm
            74.968094 = fieldWeight in 170585, product of:
              1.0 = tf(freq=1.0), with freq of:
                1.0 = termFreq=1.0
              3.1236706 = idf(docFreq=685498, maxDocs=5731988)
              24.0 = fieldNorm(doc=170585)
  1.0 = queryBoost

{category=Hotel, text=hotels in kerala, count=5.0, 
_id=525472d7d4a769f4316499ca, location={lon=93.95, lat=24.81667}, 
po=9.228571428571428}
1195.7068 = custom score, product of:
  1195.7068 = script score function: composed of:
    239.14136 = sum of:
      215.63971 = max of:
        215.63971 = sum of:
          18.701233 = weight(text:ho in 170733) [PerFieldSimilarity], 
result of:
            18.701233 = score(doc=170733,freq=1.0 = termFreq=1.0
), product of:
              0.27964544 = queryWeight, product of:
                2.7864501 = idf(docFreq=960416, maxDocs=5731988)
                0.10035904 = queryNorm
              66.8748 = fieldWeight in 170733, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                2.7864501 = idf(docFreq=960416, maxDocs=5731988)
                24.0 = fieldNorm(doc=170733)
          22.496681 = weight(text:hot in 170733) [PerFieldSimilarity], 
result of:
            22.496681 = score(doc=170733,freq=1.0 = termFreq=1.0
), product of:
              0.30671278 = queryWeight, product of:
                3.056155 = idf(docFreq=733378, maxDocs=5731988)
                0.10035904 = queryNorm
              73.34772 = fieldWeight in 170733, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                3.056155 = idf(docFreq=733378, maxDocs=5731988)
                24.0 = fieldNorm(doc=170733)
          22.589373 = weight(text:hote in 170733) [PerFieldSimilarity], 
result of:
            22.589373 = score(doc=170733,freq=1.0 = termFreq=1.0
), product of:
              0.307344 = queryWeight, product of:
                3.0624444 = idf(docFreq=728780, maxDocs=5731988)
                0.10035904 = queryNorm
              73.498665 = fieldWeight in 170733, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                3.0624444 = idf(docFreq=728780, maxDocs=5731988)
                24.0 = fieldNorm(doc=170733)
          22.600088 = weight(text:hotel in 170733) [PerFieldSimilarity], 
result of:
            22.600088 = score(doc=170733,freq=1.0 = termFreq=1.0
), product of:
              0.30741686 = queryWeight, product of:
                3.0631707 = idf(docFreq=728251, maxDocs=5731988)
                0.10035904 = queryNorm
              73.5161 = fieldWeight in 170733, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                3.0631707 = idf(docFreq=728251, maxDocs=5731988)
                24.0 = fieldNorm(doc=170733)
          129.25233 = weight(text:hotels in 170733) [PerFieldSimilarity], 
result of:
            129.25233 = score(doc=170733,freq=1.0 = termFreq=1.0
), product of:
              0.73517686 = queryWeight, product of:
                7.3254676 = idf(docFreq=10260, maxDocs=5731988)
                0.10035904 = queryNorm
              175.81122 = fieldWeight in 170733, product of:
                1.0 = tf(freq=1.0), with freq of:
                  1.0 = termFreq=1.0
                7.3254676 = idf(docFreq=10260, maxDocs=5731988)
                24.0 = fieldNorm(doc=170733)
      23.50164 = max of:
        23.50164 = weight(text:in^30.0 in 170733) [PerFieldSimilarity], 
result of:
          23.50164 = score(doc=170733,freq=1.0 = termFreq=1.0
), product of:
            0.31348857 = queryWeight, product of:
              30.0 = boost
              3.1236706 = idf(docFreq=685498, maxDocs=5731988)
              0.0033453014 = queryNorm
            74.968094 = fieldWeight in 170733, product of:
              1.0 = tf(freq=1.0), with freq of:
                1.0 = termFreq=1.0
              3.1236706 = idf(docFreq=685498, maxDocs=5731988)
              24.0 = fieldNorm(doc=170733)
  1.0 = queryBoost

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/22d737da-5951-406a-863a-24eaf95e1382%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to