I am using SolrCloud, version 8.1.1 and I have an Alias under which there are several collections, but not all of them have the same xml schema.
So I have collection "a" which has the field "is_a" and collection b which does not have this field.
Is it possible to make a query that provides a check on the "is_a" field only for the documents in collection "a"?
If I perform the query on the Alias, I get the error:
Undefined field: is_a
The error is expected as the field name is not available in another collection.
In short you cannot perform the same query on alias until and unless you have common schema defined or you need to have the name common searchable fields in he schema which is applicable/available in all the collection.
Another alternative could be create a copy field which will hold the common searchable fields. And while using alias you can search on that copy field which is holding all the searchable field required for your application.
Related
Seems that only attribute field can be imported.
Besides, fields of struct can only be attribute indexing mode.
So how can I implement function in vespa like the nested query (text field) in elasticsearch
Parent-child relationships in Vespa are implemented by indexing all parent documents on all nodes in the cluster. These are global documents.
For performance reasons, fields imported from a parent document type must be defined as attribute, which also dictates the type of matching that is supported. Similar restrictions apply for struct fields, regardless of using parent-child relationships. See https://github.com/vespa-engine/vespa/issues/12333 for a feature request on supporting different match modes for imported fields from parent document types.
Let's say you have a simple forms automation application, and you want to index every submitted form in a Solr collection. Let's also say that form content is open-ended so that the user can create custom fields on the form and so forth.
Since users can define custom forms, you can't really predefine fields to Solr, so we've been using Solr's "schema-less" or managed schema mode. It works well, except for one problem.
Let's say a form comes through with a field called "ID" and a value of "9". If this is the first time Solr has seen a field called "ID", it dutifully updates it's schema, and since the value of this field is numeric, Solr assigns it a data type of one of it's numeric data types (we see "plong" a lot).
Now, let's say that the next day, someone submits another instance of this same form, but in the ID field, they type their name instead of entering a number. Solr spits this out and won't index this record because the schema says ID should be numeric, but on this record, it's not.
The way we've been dealing with this so far is to trap the exception we get when a field's data type disagrees with the schema, and then we use the Solr API to alter the schema, making the field in question a text or string instead of a numeric.
Of course, when we do this, we need to reindex the entire collection since the schema changed, and so we need to persist all the original data just in case we need to re-index everything after one of these schema data-type collisions. We're big Solr fans, but at the same time, we wonder whether the benefits of using the search engine outweigh all this extra work that gets triggered if a user simply enters character data in a previously numeric field.
Is there a way to just have Solr always assign something like "text_general" for every field, or is there some other better way?
I would say that you might need to handle the Id values at your application end.
It would be good to add a validation for Id, that Id should be of either string or numberic.
This would resolve your issue permanently. If this type is decided you don't have to do anything on the solr side.
The alternative approach would be have a fixed schema.xml.
In this add a field Id with a fixed fieldType.
I would suggest you to go with string as a fieldType for ID if don't want it to tokenize the data and want the exact match in the search.
If you would like to have flexibility in search for the Id field then you can add a text_general field type for the field.
You can create your own fieldType as well with provided tokenizer and filter according to your requirement for you the field Id.
Also don't use the schemaless mode in production. You can also map your field names to a dynamic field definition. Create a dynamic field such as *_t for the text fields. All your fields with ending with _t will be mapped to this.
Is it possible to add fields to the schema (managed or not, does not matter) at search query time?
Basically my Solr will receive search queries for fields that I cannot anticipate. If the query contains a field that is not in the schema, i get :
"msg:undefined field"
I use Distance Function to sort results:
/select?q=city:Atlanta+_val_: dist(2,fieldX,fieldY,0,0)&fl=ticket_id,score&sort=score asc"
For example if fieldY is not in the schema, I would like Solr to give it a default value and not fail
There is an answer how I can get all solr fields names with curl
https://stackoverflow.com/a/29546298/5165781
So, do get all fields names I do
select?q=*:*&wt=csv&rows=0&facet
But how can I get fields names after I apply a filter?
For example:
if I want all solr fields names for specific date, I try : select?q=*:*&fq="dt":"2016-10-06T00:00:00Z"&wt=csv&rows=0&facet
But it returns all field names across all documents.
So, how can I retrieve fields names with specific filters?
I am working on eCommerce web application which is developed using DOT NET MVC. I use Solr to index product details. So that I have mentioned Product related fields to my Solr Schema file.
Now I also want to index SearchTerm to Solr. For this how can I manage my Schema file to store/index searchterm as my Schema file is product specific?
Can anyone please suggest?
You can have a separate core for this and define the new schema.xml for it or if you want to use the existing schema.xml then you can make use of the dynamic fields by which you need not have bother in future if any other field you need to add..
You can use Dynamic fields.
Dynamic fields allow Solr to index fields that you did not explicitly define in your schema.
This is useful if you discover you have forgotten to define one or more fields. Dynamic fields can make your application less brittle by providing some flexibility in the documents you can add to Solr.
A dynamic field is just like a regular field except it has a name with a wildcard in it. When you are indexing documents, a field that does not match any explicitly defined fields can be matched with a dynamic field.
For example, suppose your schema includes a dynamic field with a name of *_i.
If you attempt to index a document with a cost_i field, but no explicit cost_i field is defined in the schema, then the cost_i field will have the field type and analysis defined for *_i.
Like regular fields, dynamic fields have a name, a field type, and options.
<dynamicField name="*_i" type="int" indexed="true" stored="true"/>