"multiValued": false に設定したフィールドが配列として返される | KandaSearch Community Support Forum

"multiValued": false に設定したフィールドが配列として返される

トピック作成者:ks-solruserml-bot (2025/03/01 22:51 投稿)
2
OpenOpen

(The bot translated the original post https://lists.apache.org/thread/n4r3vjbttzj46ty4lsj4yb31xq135kzz into Japanese and reposted it under Apache License 2.0. The copyright of posted content is held by the original poster.)

新しいコレクションを作成し、以下のRESTリクエストを送信しました。

{
  "add-field-type": [
    {
      "name": "newInt",
      "class": "solr.IntPointField",
      "multiValued": false
    }
  ]
}
{
  "add-field": [
    {
      "name": "ANNOUNCEMENT_ID",
      "type": "newInt",
      "multiValued": false
    }
  ]
}

しかし、フィールドを取得すると以下のようになっています。

"ANNOUNCEMENT_ID": [1]

期待していたのは、単一の整数値として返されることでした。

この現象が発生する理由をご存じの方がいれば教えてください。

使用しているSOLRのバージョンは 9.7.0 です。

よろしくお願いします。

返信投稿者:ks-solruserml-bot (2025/03/01 22:52 投稿)

再現できませんでした(詳細な手順は以下の通り)が、気になる点があります。

'ANNOUNCEMENT_ID' と 'announcemenT_ID' は Solr にとって異なるフィールド名として扱われます。


実行手順:

hossman@slate:~/lucene/solr [j11] [tags/releases/solr/9.7.0] $ ./solr/packaging/build/dev/bin/solr -e techproducts

フィールドの追加:

hossman@slate:~/lucene/solr [j11] [tags/releases/solr/9.7.0] $ curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field-type": {
    "name": "newInt",
    "class": "solr.IntPointField",
    "multiValued": false
  },
  "add-field": {
    "name": "ANNOUNCEMENT_ID",
    "type": "newInt",
    "multiValued": false
  }
}' http://localhost:8983/solr/techproducts/schema

レスポンス:

{
  "responseHeader": {
    "status": 0,
    "QTime": 577
  }
}

データの追加:

hossman@slate:~/lucene/solr [j11] [tags/releases/solr/9.7.0] $ curl -X POST -H 'Content-type:application/json' --data-binary '[{
  "id": "hoss",
  "ANNOUNCEMENT_ID": 1
}]' 'http://localhost:8983/solr/techproducts/update?commit=true'

レスポンス:

{
  "responseHeader": {
    "status": 0,
    "QTime": 111
  }
}

データの取得:

hossman@slate:~/lucene/solr [j11] [tags/releases/solr/9.7.0] $ curl 'http://localhost:8983/solr/techproducts/select?wt=json&omitHeader=true&q=id:hoss'

レスポンス:

{
  "response": {
    "numFound": 1,
    "start": 0,
    "numFoundExact": true,
    "docs": [{
      "id": "hoss",
      "ANNOUNCEMENT_ID": 1,
      "_version_": 1818002101907750912,
      "_root_": "hoss"
    }]
  }
}

Hoss
http://www.lucidworks.com/

返信投稿者:ks-solruserml-bot (2025/03/01 22:52 投稿)

ありがとう、Chris。

フィールド名の大文字小文字の違いに関するヒントが解決の手がかりになりました。
私のプロジェクトの JSON シリアライザーの設定が、正しい大文字小文字でデータを送信しておらず、その結果、設定したフィールドタイプが適用されていませんでした。

トピックへ返信するには、ログインが必要です。

KandaSearch

Copyright © 2006-2025 RONDHUIT Co, Ltd. All Rights Reserved.

投稿の削除

この投稿を削除します。よろしいですか?