简体   繁体   English

使用dismax时,Solr获得计算的距离

[英]Solr get calculated distance while using dismax

I'm starting to think that what I want to do is not possible but thought I would give this a try. 我开始认为我想做的事情是不可能的,但我想我会尝试一下。

I'm running Solr 3.5. 我正在运行Solr 3.5。

I currently have two types of search: 我目前有两种类型的搜索:

  1. A basic spatial query which returns the calulated distance between two points in the score field. 一个基本的空间查询,它返回得分字段中两点之间的计算距离。

Sample Query from my Solr logs: 我的Solr日志中的示例查询:

?fl=*,score&sort=score+asc&start=0&q={!func}geodist()&sfield=coordinates&pt=59.2363514,18.092783&version=2
  1. A dismax query which allows free text queries on a number of fields. 一个dismax查询,允许在许多字段上进行自由文本查询。

Sample Query from Solr log: Solr日志的示例查询:

mm=1&d=100.0&sfield=coordinates&qf=field1^5.0+fields2^3.0&defType=edismax&version=2&fl=*,score&start=1&q=monkeyhopper&pt=59.2363514,18.0927830000&fq={!geofilt}}

I want to replace my first query with the dismax query but I really need to get the calculated distance in the response. 我想用dismax查询替换我的第一个查询,但我真的需要在响应中获得计算的距离。 Yes, I can calulate the distance programatically but I would prefer not having to do this as Solr has done it for me already. 是的,我可以以编程方式计算距离,但我不想这样做,因为Solr已经为我做了这件事。

I still want to be able to sort my dismax query "by relevance", distance or any other field so the score given by my boosts could be interesting for sorting but I don't need it to be returned. 我仍然希望能够“按相关性”,距离或任何其他字段对我的dismax查询进行排序,这样我的提升给出的分数对于排序可能很有趣,但我不需要将其返回。

If I understood correctly you want to have the result of a function in your Solr response. 如果我理解正确,您希望在Solr响应中获得函数的结果。 The SOLR-2444 issue is what you're looking for I guess: it allows to include in the fl parameter pseudo-fields, functions etc. The only problem is that it's been committed only on trunk, so it isn't available on the current Solr release, neither will be in the coming 3.6 release. 我猜想SOLR-2444问题是你想要的:它允许在fl参数中包含伪字段,函数等。唯一的问题是它只在trunk上提交,因此它不能在目前的Solr发布,也不会出现在即将发布的3.6版本中。 You have to wait for the 4 release but I don't think it will take a lot of time. 你必须等待4发布,但我认为这不会花费很多时间。 Maybe you can already start playing around with a snapshot of the last successful Jenkins build. 也许你已经可以开始玩上一次成功的Jenkins构建的快照了。

Pseudo-fields are now available in Solr 4+ which allow you to do just this. 现在,Solr 4+中提供了伪字段,您可以使用它。

http://localhost:8983/solr/collection1/browse?q=*:*&rows=1000&wt=xml&pt=37.763649,-122.24313&sfield=store&fl=dist:geodist()

For instance, this request allows me to return a field "dist" which contains the distance of each entry to the stated point. 例如,该请求允许我返回字段“dist”,其包含每个条目到所述点的距离。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM