NOW パラメータにより、Date Math で記述した “NOW” を特定の日付に設定することができます。 NOW パラメータには、いわゆる UNIX TIME の Long 値を指定します。 NOW パラメータを指定することで、複数のノードにまたがる分散検索での NOW の値を揃えることができます。テストのときにも役に立ちそうです。
TZ
TZ パラメータを指定することで、デフォルト UTC である Date Math の日付計算を別のタイムゾーンとして扱うことができます。
[
{
"id":"1",
"start_end":[
"[2020-03-01T18:00Z TO 2020-03-01T23:00Z]"
]
}
]
以下のクエリで2020年3月1日19時に営業している店舗を検索できます。
start_end:"2020-03-01T19:00:00Z"
DateRangeFieldを使うパターンだと営業時間を複数登録するのも簡単です。
[
{
"id":"2",
"start_end":[
"[2020-03-01T11:00Z TO 2020-03-01T14:00Z]",
"[2020-03-01T18:00Z TO 2020-03-01T23:00Z]",
"[2020-03-02T18:00Z TO 2020-03-02T23:00Z]",
"[2020-03-04T11:00Z TO 2020-03-04T14:00Z]",
"[2020-03-04T18:00Z TO 2020-03-04T23:00Z]"
]
}
]
クエリは先程と同じもので大丈夫です。
start_end:"2020-03-01T19:00:00Z"
DatePointFieldでstartとendの2つのフィールドを使うパターンだと、どうでしょう? start と end を multiValued にしても解決しません。
SOLR-14071: Untrusted configsets (ones that are uploaded via unsecured configset API) cannot use <lib> directive. Consider enabling authentication/authorization so that the uploaded configsets are trusted. Note: If you already have a collection using untrusted configset that uses directive, it will not load after upgrading to 8.4. You can re-upload your configset using “bin/solr zk -upconfig ..” or place your libraries in the classpath and restart Solr.
$ (cd solr-8.4.0/server/solr/configsets/sample_techproducts_configs/conf && zip -r - *) > configsets_test.zip
$ curl -X POST --header "Content-Type:application/octet-stream" --data-binary @configsets_test.zip "http://localhost:8983/solr/admin/configs?action=UPLOAD&name=configsets_test"
アップロードした configsets_test を使ってコレクションを作成します。
curl -s "http://localhost:8983/solr/admin/collections?action=CREATE&name=configsets_test&numShards=1&replicationFactor=1&collection.configName=configsets_test&omitHeader=true"
{
"failure":{
"127.0.1.1:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Error CREATEing SolrCore 'configsets_test_shard1_replica_n1': Unable to create core [configsets_test_shard1_replica_n1] Caused by: The configset for this collection was uploaded without any authentication in place, and use of is not available for collections with untrusted configsets. To use this component, re-upload the configset after enabling authentication and authorization."},
"Operation create caused exception:":"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Underlying core creation failed while creating collection: configsets_test",
"exception":{
"msg":"Underlying core creation failed while creating collection: configsets_test",
"rspCode":400},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"Underlying core creation failed while creating collection: configsets_test",
"code":400}}
$ curl --user solr:SolrRocks -s "http://localhost:8983/solr/admin/collections?action=CREATE&name=configsets_test&numShards=1&replicationFactor=1&collection.configName=configsets_test&omitHeader=true"
{
"failure":{
"127.0.1.1:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Error CREATEing SolrCore 'configsets_test_shard1_replica_n1': Unable to create core [configsets_test_shard1_replica_n1] Caused by: The configset for this collection was uploaded without any authentication in place, and use of is not available for collections with untrusted configsets. To use this component, re-upload the configset after enabling authentication and authorization."},
"Operation create caused exception:":"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Underlying core creation failed while creating collection: configsets_test",
"exception":{
"msg":"Underlying core creation failed while creating collection: configsets_test",
"rspCode":400},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"Underlying core creation failed while creating collection: configsets_test",
"code":400}}
bin/post -c mycollection data.json
POSTing file data4.json (application/json) to [base]/json/docs
SimplePostTool: WARNING: Solr returned an error #401 (require authentication) for url: http://localhost:8983/solr/mycollection/update/json/docs
SimplePostTool: FATAL: Looks like Solr is secured and would not let us in. Try with another user in '-u' parameter