2017-03-02 130 views
0

我的使用情况由距离

我写的代码,以显示与搜索功能附近的商店搜索与排序搜索词Solr的文档。我想按照给定的用例从solr中获取商店 - 如果我搜索term:“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" 
} 

请帮我,我陷严重!

回答

0

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

欲了解更多信息请参考这里:https://cwiki.apache.org/confluence/display/solr/Spatial+Search

+0

感谢您的回复,如果我查询过geodist(),然后在搜索词会{FUNC!}? –

+0

从我头脑的顶部q = _val_:mynumericfield _val _:“recip(rord(myfield),1,2,3)”请参阅此处以获取q pram中的更多多重查询。 https://wiki.apache.org/solr/SolrQuerySyntax – Yauza