如何获取除多值字段之外的所有Solr字段名称?

huangapple go评论52阅读模式
英文:

How to get all solr field names except for multivalued fields?

问题

我是新手 solr,我试图查询字段名称,排除具有 multiValued=true 的字段。

到目前为止,我有

select?q=*:*&wt=csv&rows=0&facet

这会返回所有字段。

有没有一种方法可以修改查询以检查字段是否是多值的?

英文:

I'm new to solr and I'm trying to query for field names excluding fields with multiValued=true.

So far I have

select?q=*:*&wt=csv&rows=0&facet

which returns all the fields.

Is there a way to modify the query to check if a field is multivalued?

答案1

得分: 0

你可以通过Schema API获取有关所有已定义字段的信息。如果字段被定义为多值字段,响应将包含一个名为"multiValued"的字段,其值为true:

v1 API:

http://localhost:8983/techproducts/schema/fields

v2 API:

http://localhost:8983/api/collections/techproducts/schema/fields
{
    "fields": [
        {
            "indexed": true,
            "name": "_version_",
            "stored": true,
            "type": "long"
        },
        {
            "indexed": true,
            "multiValued": true,  // 如果字段被定义为多值字段,则此处为true
            "name": "cat",
            "stored": true,
            "type": "string"
        },
    ],
    "responseHeader": {
        "QTime": 1,
        "status": 0
    }
}
英文:

You can retrieve information about all the defined fields through the Schema API. The response will contain a multiValued field set to true if the field is defined as multivalued:

v1 API:

http://localhost:8983/techproducts/schema/fields

v2 API:

http://localhost:8983/api/collections/techproducts/schema/fields
{
    "fields": [
        {
            "indexed": true,
            "name": "_version_",
            "stored": true,
            "type": "long"
        },
        {
            "indexed": true,
            "multiValued": true,  <----
            "name": "cat",
            "stored": true,
            "type": "string"
        },
    ],
    "responseHeader": {
        "QTime": 1,
        "status": 0
    }
}

huangapple
  • 本文由 发表于 2023年2月16日 09:31:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75466992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定