ruby - ElasticSearch - if field is null, treat as 0? -
i using elasticsearch, , running nullpointerexceptions because field basing score on null several documents.
how make elasticsearch treat these null fields 0?
fwiw, i'm using tire gem , ruby code:
s = tire.search "articles" query custom_score :script => "_score < 2 ? 0 : doc['num_likes'].value" match fields, keyword end end end
i discovered need this:
_score < 2 ? 0 : (doc['num_likes'].empty ? 0 : doc['num_likes'].value)
Comments
Post a Comment