我可以返回多个文档的值吗? Solr 查询中的字段?

发布于 2024-12-05 21:20:47 字数 1844 浏览 1 评论 0原文

假设我在文档架构中有这些字段:

<field name="id" type="string" indexed="true" stored="true" multiValued="false" />
<field name="type" type="string" indexed="true" stored="true" multiValued="false" />
<field name="referenceDataValues" type="string" indexed="true" stored="true" multiValued="true" />
<field name="text" type="text" indexed="true" stored="false" multiValued="true" />

文档 A 具有列出的字段的这些值:

  • id: "do not care"
  • type: "SalesOrder"
  • referenceDataValues: ["abcdefg" , "hijklmn", "opqrst"]
  • text: [ "do", "not", "care", "either"]

文档 B 具有以下值:

  • id:“不关心”
  • 类型:“SalesOrder”
  • 参考数据值: [“hijklmn”,“opqrst”]
  • 文本:[“red”,“paint”]

文档C具有以下值:

  • id:“abcdef”
  • 类型:“Customer”
  • referenceDataValues:(null)
  • 文本:[“hello”,“world” ", "how", "ya", "doing"]

文档 D 具有以下值:

  • id: "hijklmn"
  • type: "Customer"
  • referenceDataValues: (null)
  • text: ["hello", “world”、“how”、“ya”、“doing”]

默认搜索仅在文本字段上。

如果用户输入查询“SalesOrder red Paint Customer hello world”,我想构造一个仅返回文档 B 的 Solr 查询。意思是,获取引用文本为 hello 的 Customers 的(文本为红色或油漆的 SalesOrders) OR world

达到此目的的算法如下所示:

首先,此查询的结果:

q="hello world"&fq=type:Customer&fl=id

这将是文档 C 和 D,仅包含 ID。但是,我实际上希望在每个 id 字段(而不是文档)中获取这些值,这样我就可以查看它们是否存在于 SalesOrders 文档的 referenceDataValues 字段中。

q="red Paint"&fq=type:SalesOrder&fq=referenceDataValues:(此处嵌套上一个查询的 id 值)

是否可以返回第一个查询中 ID 字段的值?如果是,这个嵌套查询的语法是什么样的?

现在,我尝试使用的查询如下所示:

q=red paint&start=0&rows=25&fq=type:SalesOrder&fq=referenceDataValues:(_query_:"{!lucene fq=type:CustomerPartyMaster&fl=id} hello world")

Suppose I have these fields in a document schema:

<field name="id" type="string" indexed="true" stored="true" multiValued="false" />
<field name="type" type="string" indexed="true" stored="true" multiValued="false" />
<field name="referenceDataValues" type="string" indexed="true" stored="true" multiValued="true" />
<field name="text" type="text" indexed="true" stored="false" multiValued="true" />

Document A has these values for the listed fields:

  • id: "do not care"
  • type: "SalesOrder"
  • referenceDataValues: ["abcdefg" , "hijklmn", "opqrst"]
  • text: ["do", "not", "care", "either"]

Document B has these values:

  • id: "do not care"
  • type: "SalesOrder"
  • referenceDataValues: ["hijklmn", "opqrst"]
  • text: ["red", "paint"]

Document C has these values:

  • id: "abcdef"
  • type: "Customer"
  • referenceDataValues: (null)
  • text: ["hello", "world", "how", "ya", "doing"]

Document D has these values:

  • id: "hijklmn"
  • type: "Customer"
  • referenceDataValues: (null)
  • text: ["hello", "world", "how", "ya", "doing"]

Default search is only on the text field.

If a user enters the query, "SalesOrder red paint Customer hello world", I want to construct a Solr query that returns only Document B. Meaning, get me the (SalesOrders whose text has red OR paint) who reference Customers whose text has hello OR world

The algorithm for reaching this would be like so:

First, the results of this query:

q="hello world"&fq=type:Customer&fl=id

which would be documents C and D, containing only the IDs. However, I want to actually get these values in each of the id fields, not the documents, so I can see if they exist in the referenceDataValues fields in the SalesOrders documents.

q="red paint"&fq=type:SalesOrder&fq=referenceDataValues:(nest here the id values from the previous query)

Is it possible to return the values of the ID fields in the first query? If yes, what would the syntax look like for this nested query?

Right now, the query I am attempting to use looks like this:

q=red paint&start=0&rows=25&fq=type:SalesOrder&fq=referenceDataValues:(_query_:"{!lucene fq=type:CustomerPartyMaster&fl=id} hello world")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北方的韩爷 2024-12-12 21:20:47

您想要实现的是一种对 ids 的连接。文档 C 和 D 的 id 作为文档 A 和 B 的参考数据值中的外键

您可能需要检查连接补丁 -
https://issues.apache.org/jira/browse/SOLR-2272

如果它不起作用,您最终可能会将文档及其参考数据作为单个实体进行索引,以便您可以进行相应的搜索和过滤。

What you are trying to achieve is a kind of join on the ids. The id of Document C and D is as a foreign key in the reference data values for Document A and B

You may want to check the join patch -
https://issues.apache.org/jira/browse/SOLR-2272

If it doesn't work, you may end up indexing the documents and their reference data as a single entity, so that you can search across and filter accordingly.

锦欢 2024-12-12 21:20:47

您是否尝试过 FieldList 参数

您可以指定查询应返回哪些字段,然后只需执行第二个查询,在其中按引用DataValues:returnedID 进行过滤。

但是,当第一个查询的结果包含大量 ID 时,您需要测试它的工作原理(我正在考虑性能)。

Have you tried the FieldList parameter ??

You can specify which fields your query should return and then just do the second query where you filter by referenceDataValues:returnedID

But you need to test how it works (i am thinking about performance) when the result of the first query contains lots of IDs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文