Return SOLR response only if date is present [duplicate] - solr

This question already has answers here:
Solr - How do I construct a query that requires a NOT NULL Location field
(4 answers)
Closed 4 months ago.
I have 10 documents in solr. Out of 10 documents, only 8 documents have a field called date. I need a query to fetch only the documents that has date present in it. I already tried with fq=date:* but this is returning 0 results. Any leads would be appreciated.

Tried something like fq=date:[* TO *] and it seems to work !

Related

Different numFound between SolrJ and Solr itself

I and my team member are doing Solr indexing recently but bounced into some problems that we searched and searched yet no documents about that.
Its that we use the same query in SolrJ and on Solr Admin UI query
like "callleeID : 12 AND fraudType : (7 8 9 10)"
on exactly same table,
but I get different numFound from them, for SolrJ, totalCount = 4251, as for when I use Solr admin query, I get numFound = 4263.
Please tell me what happened and what I can do to fix it?
Below I link the two screen shots to show those differences.
screen shot1
screen shot 2
In Solr admin UI try using + instead of AND:
+callleeID:12
+fraudType:(7 8 9 10)

Sort on last_updated no longer works [duplicate]

This question already has an answer here:
multi values are getting stored in solr document by default in 5.x
(1 answer)
Closed 6 years ago.
Just upgrading from Solr 4.9 to 6.2.
Previously, "sort=last_modified desc" worked just fine (usually extracted from documents by Tika), but in 6.2 last_modified is apparently multivalued (why?) so Solr will not sort on it.
This seems like it should be such a simple thing but I've driven myself to the point of madness trying to find some documentation that will tell me:
(1) Why last_modified is multivalued?
(2) Is there a single-valued equivalent parameter I can use to sort by document date?
Which schema is that in? Usually, it is what you would define it to be. Unless you did not define it at all and used schemaless mode, in which any field added would be multivalued.
If you did use schemaless mode, just go back to a new collection and explicitly define the last_modified as you wish first, before doing indexing.

How to index words with their prefix in solr? [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
how index words with their prefix in solr?
I'm using solr 3.3. I want solr index words with their suffixes.
When I index 'book' and 'books' and search for 'book', solr shows any document that has 'book' or 'books' but when I index 'rain' and 'rainy' and search for 'rain', solr show any document that has 'rain', but I want solr to show any document that has 'rain' or 'rainy'.
Related to your previous question, Stemming is already handling the 'book' and 'books' example. As #Jayendra answered, to get a search for 'rain' to return 'rainy', you need to implement a SynonymFilterFactory and specify the synonyms you need that would match your desired search results.
Another option would be to use 'Hunspell' stemming which is based on OpenOffice dictionary files... http://wiki.apache.org/solr/Hunspell (Solr 3.5)

Regarding Boolean logic in Solr

I have a Solr index with a year field, I can query all results within a range of years using the following query which works fine
*:* AND year:[1934 TO 1950]
How would I incorporate the AND operator so I can search for results in a number of selected years, eg. results for year 1930 AND year 1950 only. I tried something like:
*:* AND year:1934 AND year:1950
the above query displays no results.
*:* AND (year:1934 OR year:1950)
Your's does not display a result because there can be no match in both years (but that's what what the expression says).
You don't need to get *:* AND year:[1934 TO 1950], just year:[1934 TO 1950] is enough.
Unless year is a multivalued field you probably want year:1934 OR year:1950

Searching for date range or null/no field in Solr [duplicate]

This question already has answers here:
using OR and NOT in solr query
(7 answers)
Closed 6 years ago.
I want to perform a search on a text field in Solr. I want to return all matches in a range or where there is no value. The two searches word independently:
myfield:[start TO finish]
-myfield:[* TO *]
The first returns all matches in the range. The second returns all matches that have no value for the "myfield" field. The problem is combining these two.
This returns no matches:
myfield:[start TO finish] OR -myfield:[* TO *]
This returns matches between start and finish, but not null entries:
myfield:[start TO finish] OR (-myfield:[* TO *])
The solution from Mauricio Scheffer worked for me until I've included it into full query. The query itself may contain up to three fields with ranges and somewhere in the middle Solr failed to process it.
I have managed to solve it with next query:
(myfield:[start TO finish] OR (*:* NOT myfield:[* TO *]))
It woked even in my complex query, so maybe it will help someone else.
I agree with Mauricio Scheffer solution.
If that can help, I transformed my initial query:
DocSource:"P" OR ( DocSource:"E" AND (MyDate:[NOW TO *] OR -MyDate:[* TO *] ) )
To
DocSource:"P" OR ( DocSource:"E" AND -( -MyDate:[* TO NOW] AND MyDate:[* TO *] ) )
The first query didn't run as expected in Solr 4.1.

Resources