Please let me know if there is a curl command which would give us the shard information of a given collection in solr. That is, information about how many shards the given collection is split into and its replication factor. I understand that it can be seen through solr admin UI. But, we are looking for the curl command which would yield the same result.
The Admin UI is a Javascript application. If you look in your browser's development tools under the "Networking" tab you'll see exactly which requests the UI are making to display the required information. You can then use the same endpoint in curl to retrieve the same information and process it according to your wishes.
The CLUSTERSTATUS endpoint will give you the information you're looking for:
http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS
{
"responseHeader":{
"status":0,
"QTime":333},
"cluster":{
"collections":{
"collection1":{
"shards":{
"shard1":{
"range":"80000000-ffffffff",
"state":"active",
"health": "GREEN",
"replicas":{
"core_node1":{
"state":"active",
"core":"collection1",
"node_name":"127.0.1.1:8983_solr",
"base_url":"http://127.0.1.1:8983/solr",
"leader":"true"},
"core_node3":{
"state":"active",
"core":"collection1",
"node_name":"127.0.1.1:8900_solr",
"base_url":"http://127.0.1.1:8900/solr"}}},
"shard2":{
"range":"0-7fffffff",
"state":"active",
"health": "GREEN",
"replicas":{
"core_node2":{
"state":"active",
"core":"collection1",
"node_name":"127.0.1.1:7574_solr",
"base_url":"http://127.0.1.1:7574/solr",
"leader":"true"},
"core_node4":{
"state":"active",
"core":"collection1",
"node_name":"127.0.1.1:7500_solr",
"base_url":"http://127.0.1.1:7500/solr"}}}},
"maxShardsPerNode":"1",
"router":{"name":"compositeId"},
"replicationFactor":"1",
"znodeVersion": 11,
"autoCreated":"true",
"configName" : "my_config",
"health": "GREEN",
"aliases":["both_collections"]
},
"collection2":{
"..."
}
},
"aliases":{ "both_collections":"collection1,collection2" },
"roles":{
"overseer":[
"127.0.1.1:8983_solr",
"127.0.1.1:7574_solr"]
},
"live_nodes":[
"127.0.1.1:7574_solr",
"127.0.1.1:7500_solr",
"127.0.1.1:8983_solr",
"127.0.1.1:8900_solr"]
}
}
Related
I had originally created in my solr schema 3 copy fields:
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-copy-field": {"source":"company_name","dest":"_text_"}}' http://my-instance/solr/listing/schema
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-copy-field": {"source":"address","dest":"_text_"}}' http://my-instance/solr/listing/schema
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-copy-field": {"source":"city","dest":"_text_"}}' http://my-instance/solr/listing/schema
However, I have recently removed these from the schema and are now composing queries in a slightly different format. More advanced queries we have the need for edismax.
However, even by turning on edismax I'm receiving an error from the solr query parser as per below. Did I break something by deleting the copy fields?
/solr/listing/select?debugQuery=on&defType=edismax&q=%3A&stopwords=true
{
"responseHeader": {
"zkConnected": true,
"status": 400,
"QTime": 1,
"params": {
"q": "*:*",
"defType": "edismax",
"debugQuery": "on",
"stopwords": "true"
}
},
"error": {
"metadata": [
"error-class",
"org.apache.solr.common.SolrException",
"root-error-class",
"org.apache.solr.common.SolrException"
],
"msg": "org.apache.solr.search.SyntaxError: Query Field '_text_' is not a valid field name",
"code": 400
}
}
As per the comments the 'text' field remains in 3 places in the config:
"/update/extract":{
"startup":"lazy",
"name":"/update/extract",
"class":"solr.extraction.ExtractingRequestHandler",
"defaults":{
"lowernames":"true",
"fmap.content":"_text_"}}
"spellchecker":{
"name":"default",
"field":"_text_",
"initParams":[{
"path":"/update/**,/query,/select,/tvrh,/elevate,/spell,/browse",
"defaults":{"df":"_text_"}}]
As per the comment on my question (I'm still on the learning path of solr):
Although they have been deprecated for quite some time, Solr still has
support for Schema based configuration of a <defaultSearchField/>
(which is superseded by the df parameter) and <solrQueryParser defaultOperator="OR"/> (which is superseded by the q.op parameter.
If you have these options specified in your Schema, you are strongly
encouraged to replace them with request parameters (or request
parameter defaults) as support for them may be removed from future
Solr release.
For our purposes and as we are using the edismax query parser we needed to specify the query fields that we wanted to use.
2+ year old post, not sure this will help.
Since you are using "defType": "edismax"
try "q.alt": "*:*" instead of "q": "*:*". This should fix the issue.
When I try searching for products that are having "camel" in their display names. All the indexing procedure have been done. The problem here is:
When I search "camel" I get: 1 product
"name": "CHANEL HYDRA BEAUTY CAMELLIA WATER CREAM ILLUMINATING HYDRATING FLUID 30ML"
But When I search "CAMELL": I get 3 products from solr:
{
"name": "CLE DE PEAU Lipstick #5 Camellia"
},
{
"name": "CHANEL HYDRA BEAUTY CAMELLIA WATER CREAM ILLUMINATING HYDRATING FLUID 30ML"
},
{
"name": "HERA Rouge Holic Shine No.315 Camellia Orange"
}
When I search CAMEL. I must have got these 3 as well. Why isn't it working?
The issue was fixed after setting the wildcard flag as true to the indexed properties, in Hybris. Thanks to everyone for your help and ideas.
I have a client application leveraging Microsoft Graph to get incremental changes for a certain AAD Group.
My BVT caught an issue and when I debugged, I found the Graph request does not return the members#delta collection any longer so the app did not receive any Group Membership changes.
Request:
https://graph.microsoft.com/v1.0/groups/delta?$expand=members&$select=id,displayName,mailNickName,onPremisesSecurityIdentifier,groupTypes,securityEnabled&$filter=id eq '9f63ad39-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx'
Response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups(id,displayName,mailNickname,onPremisesSecurityIdentifier,groupTypes,securityEnabled,members())",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/groups/delta?$skiptoken=duo2tEVrL.............................-Ay-zlyuo2tEVrLOUh0PUTdXM",
"value": [
{
"displayName": "TestGroup-OneUser",
"mailNickname": "9a234b7e8ad-3",
"securityEnabled": true,
"id": "9f63ad39-xxxx-xxxx-xxxx-xxxxxxxxxx",
"members#delta": [
{
"#odata.type": "#microsoft.graph.user",
"id": "18e2a00c-xxxx-xxxx-a9a9-xxxxxxxxxxxxx"
}
]
}
]
}
Any idea what has changed?
You should add members to $select, change the request like this:
https://graph.microsoft.com/v1.0/groups/delta?$select=id,displayName,members&$filter=id eq '1068699c-044b-4846-b45a-4137e06a7ca2'
In the Solr documentation it focuses explanations on how to use the GET parameters to define queries, but gives very little information on how to accomplish the same tasks using the better structured JSON POST support. I have been unable to find any documentation that goes deeper than very surface-level explanation.
Particularly, I'm trying to utilize local params in my queries and would like to know how to accomplish the following using a JSON POST instead of GET params:
http://localhost:8983/solr/city/query?sort={!sfield=location pt=35.5514,-97.4075}geodist() asc&q={!geofilt sfield=location pt=35.5514,-97.4075 d=5}
According to JSON Request API / Parameters Mapping your query would map to:
{
"sort": "{!sfield=location pt=35.5514,-97.4075}geodist() asc",
"query": "{!geofilt sfield=location pt=35.5514,-97.4075 d=5}"
}
Just to complete #MatsLindh answer, you can use usual parameter names as long as you wrap them in params (no mapping needed), for example :
file.json
{
"params": {
"q":"{!geofilt sfield=location pt=35.5514,-97.4075 d=5}",
"sort":"{!sfield=location pt=35.5514,-97.4075}geodist() asc",
"wt": "json",
"indent": "true"
}
}
Request example using curl :
curl -H "Content-Type: application/json" -X "POST" --data #file.json http://localhost:8983/solr/city/query
I'm doing the most basic of solr queries with faceting.
q=*:*&facet=true&facet.field=year
And I'm getting an error as follows:
{
"responseHeader": {
"status": 400,
"QTime": 1,
"params": {
"indent": "true",
"q": "*:*&facet=true&facet.field=year",
"_": "1443134591151",
"wt": "json"
}
},
"error": {
"msg": "undefined field *",
"code": 400
}
}
This query is straight out of the online tutorials. Why is solr complaining?
It appears that what you have done is gone to the Solr Admin panel and in the query section you have put
*:*&facet=true&facet.field=year
after the q. What you need to do is put *:* after the q, and facet=true&facet.field=year under Raw Query Parameters.
The error says, that you have "undefined field". Is "year" field defined in your schema? Also, can you give details about how you are querying the data. Like which client?And I assume that q=: is working and issue is only with faceting
You've put it into the wrong line in the solr admin.
Just take the same line, and paste it into the Raw query line instead of the query line.