sách gpt4 ai đã đi

solr - 在solr中查询具有不同字段的多个集合

In lại 作者:行者123 更新时间:2023-12-03 23:23:16 26 4
mua khóa gpt4 Nike

鉴于以下(单核)查询:

http://localhost/solr/a/select?indent=true&q=*:*&rows=100&start=0&wt=json
http://localhost/solr/b/select?indent=true&q=*:*&rows=100&start=0&wt=json

第一个查询返回 "numFound":40000"
第二个查询返回 "numFound":10000"

我尝试通过以下方式将这些放在一起:
   http://localhost/solr/a/select?indent=true&shards=localhost/solr/a,localhost/solr/b&q=*:*&rows=100&start=0&wt=json

现在我得到“numFound”:50000”。
唯一的问题是“a”的列比“b”多。所以多个集合请求只返回a的值。

是否可以查询具有不同字段的多个集合?或者它们必须相同?我应该如何更改我的第三个 url 以获得此结果?

1 Câu trả lời

你需要的是——我称之为——统一核心。该架构本身将没有内容,它仅用作一种包装器来统一您想要从两个核心显示的那些字段。在那里你需要

  • 一个 schema.xml,它包含了您希望在统一结果中包含的所有字段
  • 为您组合两个不同核心的查询处理程序

  • 事先取自 the Solr Wiki page about DistributedSearch 的重要限制

    Documents must have a unique key and the unique key must be stored (stored="true" in schema.xml) The unique key field must be unique across all shards. If docs with duplicate unique keys are encountered, Solr will make an attempt to return valid results, but the behavior may be non-deterministic.



    例如,我有带有字段 id、title、description 的 shard-1 和带有字段 id、title、abstractText 的 shard-2。所以我有这些模式

    分片 1 的架构





    type="int" indexed="true" stored="true" multiValued="false" />

    type="text" indexed="true" stored="true" multiValued="false" />

    type="text" indexed="true" stored="true" multiValued="false" />




    分片 2 的架构





    type="int" indexed="true" stored="true" multiValued="false" />

    type="text" indexed="true" stored="true" multiValued="false" />

    type="text" indexed="true" stored="true" multiValued="false" />




    为了统一这些模式,我创建了第三个模式,我称之为分片统一,它包含所有四个字段。





    type="int" indexed="true" stored="true" multiValued="false" />

    type="text" indexed="true" stored="true" multiValued="false" />

    type="text" indexed="true" stored="true" multiValued="false" />

    type="text" indexed="true" stored="true" multiValued="false" />




    现在我需要利用这个组合模式,所以我在 solr-unification 核心的 solrconfig.xml 中创建了一个查询处理程序



    edismax
    *:*
    id title description abstractText
    *,score
    100%




    就是这样。现在 shard-1 和 shard-2 中需要一些索引数据。要查询统一结果,只需使用适当的分片参数查询分片统一。
    http://localhost/solr/shard-unification/select?q=*:*&rows=100&start=0&wt=json&shards=localhost/solr/shard-1,localhost/solr/shard-2

    这将返回一个结果,如

    {
    "responseHeader":{
    "status":0,
    "QTime":10},
    "response":{"numFound":2,"start":0,"maxScore":1.0,"docs":[
    {
    "id":1,
    "title":"title 1",
    "description":"description 1",
    "score":1.0},
    {
    "id":2,
    "title":"title 2",
    "abstractText":"abstract 2",
    "score":1.0}]
    }}

    获取文档的原始分片

    如果要将原始分片提取到每个文档中,只需指定 [shard]fl .作为查询的参数或在请求处理程序的默认值中,请参见下文。括号是强制性的,它们也将出现在结果响应中。



    edismax
    *:*
    id title description abstractText
    *,score,[shard]
    100%




    工作样本

    如果您想查看运行示例,请查看 my solrsample project在 github 和 execute the ShardUnificationTest 上.我现在还包括了分片提取。

    关于solr - 在solr中查询具有不同字段的多个集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19313910/

    26 4 0
    Bài viết được đề xuất: kubernetes - 如何诊断停滞的Kubernetes部署/部署?
    Bài viết được đề xuất: rspec - 如何在 FactoryGirl 中获取随机数?
    Bài viết được đề xuất: r - 按索引组合列表列表的元素
    Bài viết được đề xuất: 从某个日期开始每天运行的 Cron 表达式
    行者123
    Hồ sơ cá nhân

    Tôi là một lập trình viên xuất sắc, rất giỏi!

    Nhận phiếu giảm giá Didi Taxi miễn phí
    Mã giảm giá Didi Taxi
    Giấy chứng nhận ICP Bắc Kinh số 000000
    Hợp tác quảng cáo: 1813099741@qq.com 6ren.com