如何将Spatial Solr添加到Solrnet查询(How to add Spatial Solr to a Solrnet query)
我在使用码头的Windows机器上运行Solr。 我已经下载了我最终设法启动并运行的Spatial Solr插件 。 我也使用Solrnet从我的asp.net mvc项目查询Solr。
现在,将数据添加到我的索引似乎工作正常,并且SpatialTierUpdateProcessorFactory也工作。
问题是:
如何使用Solrnet库将空间查询添加到正常查询中。 我曾尝试使用“ExtraParams”参数添加它,但是这并没有很好地发挥作用。
这里是我试图将空间查询与数据范围查询结合起来的一个例子。 日期范围查询在没有附加空间查询的情况下正常工作:
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的以下查询:
(({!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])
我收到的错误信息是:
远程服务器返回错误:(400)错误的请求。
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 Admin页面并对它执行以下查询,则一切正常。
{!spatial lat=50.8371 long=4.35536 radius=100 calc=arc unit=km threadcount=2}text:London
使用SolrNet调用空间函数的最佳/正确方法是什么? 以某种方式将查询手动添加到查询字符串中的最佳方法是如何?
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.
Now, adding data into my index seems to work fine and the SpatialTierUpdateProcessorFactory does work as well.
The problem is:
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);
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:
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: "}" ...
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
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?
原文:https://stackoverflow.com/questions/2788450
最满意答案
你有没有尝试过:
team2.setPlayers(team1.getPlayers(); team1.setPlayers(null); for (Player player : team2.getPlayers() { player.setTeam(team2); }
Have you tried:
team2.setPlayers(team1.getPlayers(); team1.setPlayers(null); for (Player player : team2.getPlayers() { player.setTeam(team2); }
相关问答
更多-
JPA + Hibernate - 从@OneToMany关系重新连接实体(JPA+Hibernate - Reconnecting entities from a @OneToMany relationship)[2022-09-05]
你有没有尝试过: team2.setPlayers(team1.getPlayers(); team1.setPlayers(null); for (Player player : team2.getPlayers() { player.setTeam(team2); } Have you tried: team2.setPlayers(team1.getPlayers(); team1.setPlayers(null); for (Player player : team2.getPlayers( ... -
具有OneToMany hibernate关系条件的JPA查询(JPA query with condition for OneToMany hibernate relationship)[2023-08-28]
根据您的评论并假设您将ChatThread上的OneToMany关系作为Listmessages ,您的JPQL查询应如下所示: SELECT chatThread FROM ChatThread chatThread WHERE (chatThread.userId) = (:id) AND NOT EXISTS (SELECT message FROM chatThread.messages message WHERE message.read = TRUE) 如果不使用布尔到整数 ... -
通过设置 @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "mother") public Set
getChildren() { return children; } 您声明了mappedBy=mother ,这意味着User是关系的拥有实体,并且关系在mother字段上设置。 在JPA / Hibernate中,拥有方用于持久化并保持实体之间的关系。 请看一下: https : //stac ... -
使用上面的映射,没有创建连接表。 OneToMany不需要连接表,您将在Many侧获得外键列。 这是我在使用您的代码时得到的: create table Person ( id bigint not null, primary key (id) ) create table Relationship ( id bigint not null, personFrom_id bigint, personTo_id bigint, primary key (id) ...
-
这非常简单: customer.addOrder(order); 这就是你所需要的一切。 这是ORM的原则。 您操纵对象,ORM使用您定义的映射将它们保存在数据库中。 It's extremely simple: customer.addOrder(order); That's all you need. That's the principle of an ORM. You manipulate objects, and the ORM saves them in the database using ...
-
您需要另一个OneToMany关系:确保db表中的两列代表Feedback : author和receivee :它们将指向employee表的主键,因此它们必须具有相同的类型。 添加外键约束:它们都应指向employee表的主键。 然后,按照zbigniew的回答中的解释,用Java映射关系: 反馈类: @ManyToOne @JoinColumn(name="author") private Employee author; @ManyToOne @JoinColumn(name="receivee" ...
-
默认情况下,单向@OneToMany关系将使用连接表,它将执行操作作为我的问题。 如果您使用JPA2并且不在父级上使用多态,则可以添加@JoinColumn ,这将在子表而不是另一个连接表上创建外键。 然后JPA提供程序将不执行删除并重新插入。 By default, a unidirectional @OneToMany relationship will use a join table, it will perform operation as my question. If you are usin ...
-
使用JPQL select v from Visitor v left join fetch v.category 如果你有重复项,请尝试使用distinct select distinct v from Visitor v left join fetch v.category Use JPQL select v from Visitor v left join fetch v.category if you will have duplicates try to use distinct selec ...
-
使用orphanRemoval : @OneToMany(mappedBy="classroom", cascade={CascadeType.ALL}, orphanRemoval=true) 每当从持久集中删除条目时,它将被删除。 这意味着您需要使用持久集 。 即你不能更换套装,而应该做: classroom.getRoster().clear(); classroom.getRoster().addAll(newRoster); 示例如何将持久集与用户所需的集同步: /** * Assemble ...
-
为了与JPA和Hibernate保存OneToMany关系(Order to save OneToMany relationship with JPA and Hibernate)[2022-08-23]
首先,您需要在channel对象中设置subscription ,该对象引用它并且该值不可为空。 这是你收到的例外的原因。 这种类型的映射在OutputChannel表中创建了AgentSubscription外键,因此您始终必须设置它,级联与否。 Hibernate不会执行任何自动设置或某种自动设置。 所以就你的代码来说,添加 channel.setSubscription(subscription); 在DAO插入调用之前应该解决问题。 这样,当调用entityManager.persist(subs ...