如何Solr的空间添加到Solrnet查询 [英] How to add Spatial Solr to a Solrnet query

查看:168
本文介绍了如何Solr的空间添加到Solrnet查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的Windows机器上使用的码头运行Solr的。我已经下载了空间Solr的插件我终于成功地启动和运行。我也使用Solrnet从我的asp.net MVC项目对查询Solr的。

I am running Solr on my windows machine using jetty. I have downloaded the Spatial Solr Plugin which I finally managed to get up and running. I am also using Solrnet to query against Solr from my asp.net mvc project.

现在,将数据添加到我的指数似乎好工作和SpatialTierUpdateProcessorFactory不工作,以及

Now, adding data into my index seems to work fine and the SpatialTierUpdateProcessorFactory does work as well.

的问题是:

如何添加空间查询使用Solrnet库我的正常查询。我曾尝试使用ExtraParams参数添加它,但没有很好地工作。

How do I add the spatial query to my normal query using the Solrnet library. I have tried adding it using the "ExtraParams" parameter but that didn't work very well.

下面是我试图空间查询与数据相结合的例子范围查询。日期范围查询工作正常不附加给它的空间查询:

Here is an example of me trying to combine the spatial query with a data range query. The date range query works fine without the spatial query attached to it:

new SolrQuery("{!spatial lat=51.5224 long=-2.6257 radius=10000 unit=km calc=arc threadCount=2}") && new SolrQuery(MyCustomQuery.Query) && new SolrQuery(DateRangeQuery);



这会导致对Solr的以下查询:

which results in the following query against Solr:

(({!spatial lat=51.5224 long=-2.6257 radius=100 unit=km calc=arc threadCount=2} AND *:*) AND _date:[2010-05-07T13:13:37Z TO 2011-05-07T13:13:37Z])

和错误消息我得到的回复是:

And the error message I get back is:

远程服务器返回错误:(400)错误的请求。

The remote server returned an error: (400) Bad Request.

SEVERE: org.apache.solr.common.SolrException: org.apache.lucene.queryParser.Pars
eException: Cannot parse '(({!spatial lat=51.5224 lng=-2.6257 radius=10000 unit=
km calc=arc threadCount=2} AND *:*) AND _date:[2010-05-07T13:09:49Z TO 2011-05-0
7T13:09:49Z])': Encountered " <RANGEEX_GOOP> "lng=-2.6257 "" at line 1, column 2
4.
Was expecting:
    "}" ...

现在的事情是,如果我使用Solr的Web管理页面,并反对它执行以下查询,一切工作正常。

Now, the thing is if I use the Solr Web Admin page and execute the following query against it, everything works fine.

{!spatial lat=50.8371 long=4.35536 radius=100 calc=arc unit=km threadcount=2}text:London

什么是调用使用空间功能SolrNet最好/正确的方法。是以某种方式手动添加查询该位来查询字符串的最佳方式,是又如何?

What is the best/correct way to call the spatial function using SolrNet. Is the best way to somehow add that bit of the query manually to the query string and is so how?

推荐答案

使用 LocalParams 类来表示的 Solr中 LocalParams:

Use the LocalParams class to represent LocalParams in Solr:

solr.Query(new LocalParams {
    {"type", "spatial"},
    {"lat", "-51.5224"},
    {"long", "-2.6257"},
    {"radius", "10000"},
    {"unit", "km"},
    {"calc", "arc"},
    {"threadCount", "2"},
} + Query.Field("text").Is("London"));

这是可作为SolrNet 0.3.0b1的。

This is available as of SolrNet 0.3.0b1.

这篇关于如何Solr的空间添加到Solrnet查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆