I am trying to find the document with the latest date in Solr. Is there an efficient way of doing this with the Solr query syntax ?
For now, I have been reading the documentation, but I am only getting "numFound": 0 when I try to query any date in the fq parameter, even though that date does exist in the document.
Example query:
q box:
*:*
fq box:
date_published:"2019-02-28T11:57:29.926Z"
I defined in the schema this field like so:
<field name="date_published" type="pdate" indexed="true" stored="true" required="true"/>
<fieldType name="pdate" class="solr.DatePointField" docValues="true"/>
The above date does exist with the document, but it shows "numFound":0. Although this issue is just a first step, I would actually like to find the latest document with the latest date.
Related
We are trying to sort on a multivalued field which is defined like this:
<fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
<field docValues="true" indexed="true" multiValued="true" name="fieldName" type="StrField"/>
The Solr we use is: 6.0.1.1.2338
When trying to sort on the field "fieldName", we get the following error:
"msg": "can not sort on multivalued field: fieldName",
Then we tried to use field functions to enable the sorting:
&sort=field(fieldName,min)+asc
Or like:
&fl=fieldName_alias:field(fieldName,min)&sort=fieldName_alias+asc
Then we are getting the following error:
"Selecting a single value from a multivalued field is not supported for this field: fieldName(type: StrField)"
Doing more research, we realised that the field-Function can only work for numeric types. Now we are not sure, how to implement the sorting. I hope it is possible to do without reindexing.
Any help would be very much appreciated! Thank you very much in advance!
We are trying to use Solr to search our document contents, however I want to be able to search for fields that match internally. I have looked but cannot find anything on self-referential or inner joins.
So for example:
<doc>
<field name="id">12345</field>
<field name="author">Smith</field>
<field name="last_edit">Smith</field>
...
</doc>
Obviously a (author:Smith AND last_edit:Smith) would work, but I would like to be able to search for all documents where author and last_edit are the same, not necessarily a fixed value. Defining a new field is fine.
Need to index small binary strings with SOLR but failed to do so. Actually I'm trying to search on hashes like SHA-1, MD5 and things like UUID.
Have binary field intended to be indexed.
<field name="fi" type="binary" indexed="true" stored="true" required="false" multiValued="false" />
Have binary type definition.
<fieldtype name="binary" class="solr.BinaryField"/>
Why any try to select on this field even with fi:* request cannot find anything? Any alternative to my approach?
if your data is just SHA1 etc, I think you can perfectly make this work with a StrField. Of course if you need prefix searches be sure to properly analyze it with solr.EdgeNGramTokenizerFactory.
Regarding the binary field you are using, I never had to use it myself, but what apparently does is encode in base64 whatver you send, and index it then, so you can reallly send binary data (like an .exe file).
I'm having trouble querying on a StrField with a large value (say 70k characters). I'm using Solr 4.4 and have documents with a string type:
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
and field:
<dynamicField name="someFieldName_*" type="string" indexed="true" stored="true" />
Note that it's stored, in case that matters.
Across my documents, the length of the value in this StrField can be up to ~70k characters or more.
The query I'm trying is someFieldName_1:*. If someFieldName_1 has values with length < 32,767 characters, then it works fine and I get back various documents with values in that field.
However, if I query someFieldName_2:* and someFieldName_2 has values with length >= 32,767, I don't get back any documents. Even though I know that many documents have a value in someFieldName_2.
I know this because I query *:* and see documents with (large) values in someFieldName_2.
So is there some type of limit to the length of strings in a StrField that I can query against? 32,767 = 2^15 is mighty suspicious =)
Yonik answered this question on the Solr user mailing list with, "I believe that's the maximum size of an indexed token...". So it seems like the behavior is somewhat expected.
However, another user has opened up a bug report about the lack of errors, "i'll open a bug to figure out why we aren't generating an error for this at index time, but the behavior at query time looks correct..."
I am indexing a collection of xml document with the next structure:
<mydoc>
<id>1234</id>
<name>Some Name</name>
<experiences>
<experience years="10" type="Java"/>
<experience years="4" type="Hadoop"/>
<experience years="1" type="Hbase"/>
</experiences>
</mydoc>
Is there any way to create solr index so that it would support the next query:
find all docs with experience type "Hadoop" and years>=3
So far my best idea is to put delimited years||type into multiValued string field, search for all docs with type "Hadoop" and after that iterate through the results to select years>=3. Obviously this is very inefficient for a large set of docs.
I think there is no obvious solution for indexing data coming from the many-to-many relationship. In this case I would go with dynamic fields: http://wiki.apache.org/solr/SchemaXml#Dynamic_fields
Field definition in schema.xml:
<dynamicField name="experience_*" type="integer" indexed="true" stored="true"/>
So, using your example you would end up with something like this:
<mydoc>
<id>1234</id>
<name>Some Name</name>
<experience_Java>10</experience_Java>
<experience_Hadoop>4</experience_Hadoop>
<experience_Hbase>1</experience_Hbase>
</mydoc>
Then you can use the following query: fq=experience_Java:[3 to *]