5

询问

{"query":{"query_string":{"query":"name:pi*"}}}

输出

hits: [
{
    _score: 1
    _source: {
        handle: PIXIES
        name: Pixies
    }
}
{
    _score: 1
    _source: {
        handle: twentyonepilots
        name: twenty one pilots
    }
}
{
    _score: 1
    _source: {
        handle: Antonio_Pinto
        name: Antonio Pinto
    }
}
{
    _score: 1
    _source: {
        handle: null
        name: Piano Tribute Players
    }
}
{
    _score: 1
    _source: {
        handle: null
        name: Los Pinguos
    }
}
{
    _score: 1
    _source: {
        handle: null
        name: Piyush Mishra & Bhupesh Singh
    }
}
{
    _score: 1
    _source: {
        handle: pinkfloyd
        name: Pink Floyd
    }
}]

如果您查看结果,它会将名称中的术语与 pi* 匹配,这是我对上述查询的期望。

但是如何编写查询以在字段中使用术语位置(位置索引)对结果进行排序。该查询的结果应该使Piano Tribute Players,Pink Floyd弹出列表顶部。因为它们以 pi* 开头

关于 solr 的类似问题:SOLR: Boosting based on location of search term in field

4

0 回答 0