【问题标题】:Search solr docs by search term with sort by distance通过按距离排序的搜索词搜索 solr 文档
【发布时间】:2017-07-22 02:06:51
【问题描述】:

我的用例

我正在编写代码以显示具有搜索功能的附近商店。我想根据给定的用例从 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"
}

请帮帮我,我卡得很厉害!!

【问题讨论】:

    标签: java search elasticsearch solr


    【解决方案1】:

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

    更多信息请看这里:https://cwiki.apache.org/confluence/display/solr/Spatial+Search

    【讨论】:

    • 感谢您的回复,如果我在查询中传递 {!func}geodist() ,那么搜索词会去哪里?
    • 从我的脑海中 q=_val_:mynumericfield val:"recip(rord(myfield),1,2,3)" 参考这里更多的查询q 婴儿车。 wiki.apache.org/solr/SolrQuerySyntax
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多