按搜索词搜索solr文档,沿距离排序



我的用例

我正在编写代码,以显示附近的搜索功能的商店。我想按照给定的用例从Solr那里获取商店 - 如果我搜索" Allen so",那么所有附近的商店都以" Allen So"的术语开始。和最近的商店应该出现。*

现有查询

{ 
  q: 'allen so*',
  defType: 'edismax',
  pt: '28.4836556,77.1074802',
  qf: 'shop_name^4 cat^3 sub_cat^2',
  fl: '*,distance:geodist()',
  start: '0',
  sort: 'geodist() asc',
  rows: '20',
  sfield: 'shop_loc',
  wt: 'json' 
}

通过击中查询,我没有得到相关的结果。

文档结构:

{
    "shop_id": "1",
    "shop_name": "Allen Solly",
    "shop_nickname": "Allen Solly",
    "shop_summary": "A search of the AAAC archives yields little about Allen Solly suits except the fact that they were sold about fifty years ago. These days they appear to be mainly a woman's brand, mainly focussed only on casual or business casual clothes, and mainly popular in India. Yet the label says "Established 1744 / Nottingham, England."",
    "shop_description": "A search of the AAAC archives yields little about Allen Solly suits except the fact that they were sold about fifty years ago. These days they appear to be mainly a woman's brand, mainly focussed only on casual or business casual clothes, and mainly popular in India. Yet the label says "Established 1744 / Nottingham, England."",
    "shop_address_1": "MGF Metropolitan Mall, MG Rd, Heritage City, Sector 25, Gurugram, Haryana 122002",
    "shop_address_2": "Gurgaon, Haryana, India",
    "shop_city": "Gurgaon",
    "shop_state": "Haryana",
    "shop_country": "India",
    "shop_area_code": "122002",
    "shop_opening_time": "11:00:00",
    "shop_closing_time": "19:00:00",
    "shop_working_days": "Sunday Monday Tuesday Wednesday Thursday Friday Saturday",
    "currency": "INR",
    "active": true,
    "user_id": "4",
    "created_at": "2016-11-29T10:07:17Z",
    "updated_at": "2016-11-29T10:07:20Z",
    "cat": [
      "Clothing & Accessories"
    ],
    "sub_cat": [
      "mens casual shirts",
      "mens sweater"
    ],
    "shop_loc": "28.480853965280254,77.08022397011518"
}

请帮助我,我很难陷入困境!

对于空间查询,您必须使用空间过滤器获得正确的结果。如果您希望距离为文档分数,则q参数需要{!func} geodist()。否则,您可以在FQ中使用GeoFilt解析器。

有关更多信息,请参阅此处:https://cwiki.apache.org/confluence/display/solr/solr/spatial Search

最新更新