あなたの説明に基づいて回答を更新しました。調査する必要がある 4 つのケースがあります。 1 SN が存在する 2 SN が存在しない 2.1 SN の前に範囲を取得する 2.2 SN の後に範囲を取得する
直観的には、間違いなく 2 つのブロックに分割します。1 つの SN が存在するため、それをクライアントに返します。これは次のようになります。
http://solrserver.us-west-2.compute.amazonaws.com:8983/solr/hellosolr/select?indent=on&q=id:S9V7464-APL-KIT3&wt=json
応答は次のようになります。
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"id:S9V7464-APL-KIT3",
"indent":"on",
"wt":"json"}},
"response":{"numFound":1,"start":0,"docs":[
{
"id":"S9V7464-APL-KIT3",
...
SN が存在しない場合、応答は "numFound":1 を返します。これは、検索を実行する必要がある場合です。したがって、ドキュメントがない場合、クエリは次のようになります。
http://solrserver.us-west-2.compute.amazonaws.com:8983/solr/hellosolr/select?indent=on&q=id:S9V7464-APL-KIT5&rows=1&sort=id%20asc&start=0&wt=json
応答は次のようになります。
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"id:S9V7464-APL-KIT5",
"indent":"on",
"start":"0",
"sort":"id asc",
"rows":"1",
"wt":"json"}},
"response":{"numFound":0,"start":0,"docs":[]
}}
2.1 したがって、SN の前に次のネイバーが必要です。降順検索に追加したいことが 2 つあります。並べ替えと、回答数の制限です。クエリは次のようになります。
http://solrserver.us-west-2.compute.amazonaws.com:8983/solr/hellosolr/select?indent=on&q=id:[*%20TO%20S9V7464-APL-KIT5]&rows=1&sort=id%20desc&start=0&wt=json
応答は次のようになります。
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"id:[* TO S9V7464-APL-KIT5]",
"indent":"on",
"start":"0",
"sort":"id desc",
"rows":"1",
"wt":"json"}},
"response":{"numFound":25,"start":0,"docs":[
{
"id":"S9V7464-APL-KIT3",
"name":["Belkin Mobile Power Cord for iPod w/ Dock"],
"manu":["Belkin"],
"manu_id_s":"belkin",
"cat":["electronics",
"connector"],
"features":["car power adapter, white"],
"weight":[6.7],
"price":[19.95],
"popularity":[1],
"inStock":[false],
"store":["45.18014,-93.87741"],
"manufacturedate_dt":"2005-08-01T16:30:25Z",
"_version_":1547654166135963648}]
}}
2.2 返されたドキュメントの数によってソートおよび制限された、昇順の範囲が必要です。何かのようなもの:
http://solrserver.us-west-2.compute.amazonaws.com:8983/solr/hellosolr/select?indent=on&q=id:[S9V7464-APL-KIT5%20TO%20*]&rows=1&sort=id%20asc&start=0&wt=json
応答は次のようになります。
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"id:[S9V7464-APL-KIT5 TO *]",
"indent":"on",
"start":"0",
"sort":"id asc",
"rows":"1",
"wt":"json"}},
"response":{"numFound":8,"start":0,"docs":[
{
"id":"S9V7464-APL-KIT7",
"name":["Belkin Mobile Power Cord for iPod w/ Dock"],
"manu":["Belkin"],
"manu_id_s":"belkin",
"cat":["electronics","connector"],
"features":["car power adapter, white"],
"weight":[6.7],
"price":[19.95],
"popularity":[1],
"inStock":[false],
"store":["45.18014,-93.87741"],
"manufacturedate_dt":"2005-08-01T16:30:25Z",
"_version_":1547654166137012224}]
}}
行を増やすと、より多くのドキュメントが返されます。開始を変更すると、N 番目の隣接を取得するためのオフセットとして使用できます。