Match all documents in a search index - google-app-engine

I have a search index of documents and I would like to send a query to get all of them. Is that possible?
Note:
It seems that "/" or "?" work but only on my dev server. When deployed to prod these queries do not return any result.

The '?' or '/' that works for you on the dev_server shouldn't have happened. The docs on this link says that the punctuators including the '?' or '/' act as word tokenizers only.
In order to retrieve all the results i would suggest a smart way to index the documents, maybe use another field using which such a solution is possible. A type date field, and a created_at query on a - created_at > epoch_time or something similar from the past.

Related

Solr does not search data in correct fashion

We have a customer web application, which uses Apache Solr APIs internally. We do not have access to the SolrUI on customer site.
Due to recent changes in Solr at customer end, whenever we try to search the data like
NAME:PRANAV AND AGE:1, Solr does not show any results.(shows numFound:0)
whereas when we search
NAME=PRANAV AND AGE:1, it gives the result.(shows numFound value greater than 0)
So String searches works with = and numeric search works with :.
But when we search
NAME=PRA* , we do not get any result in Solr. (shows numFound:0)
Can someone please advise, what should be changed on Solr side to correct the searches?
We want to have wild card searches (*, ?) to work and also String search should work with : instead of =.

solr url filter query construction

I need to make a solr query through url and I do:
Query has to be
name:john AND id:5
Filter Query
byr:75 OR byr:90
I tried doesn't seem to work
url.....?q=name:john+id:5&fq=(byr:75 OR byr:90)
I know that AND is + but what is the symbol for OR? Couldn't find much online so seeking help here
+ is not the symbol for AND - it means that the clause is required for the document to be considered a match. And in this case, it seems to only be the escape code for a space in the URL.
Use " AND " if both clauses are required (the default behavior is affected by q.op and mm if you're using dismax).
fq=byr:(75 90) will give you a search against byr field with two possible values. This is sort of described right at the end of the Standard Query Parser documentation.
I would recommend reading that whole article. And don't confuse + sign used in the query and + used in URL to escape special characters.

/select with 'q' parameter does not work

Whenever i query with q=: it shows all the documents but when i query with q=programmer 0 docs found.(contents is the default search field)
my schema has: id(unique),author,title,contents fields
Also query works fine for:
q=author:"Value" or q=title:"my book" etc, only for contents field no results.
Also when i query using spell checker(/spell?q=programmer) output shows spelling suggestions for this word,when 'programmer' is the right word and present in many documents.
I referred the example docs for configurations.
All of a sudden i am getting this,initially it worked fine.
I guess there some problem only in the contents field,but cannot figure it out.
Is it because indexes are not created properly for contents field?
(I am using solr 4.2 on Windows 7 with tomcat as webserver)
Please help.Thanks a lot in advance.
Are you sure you set the default search field? The reason you have this problem might be because you didn't set the <defaultSearchField> field in your schema.xml file. This is why "q=author:value" works while q=WHATEVER doesn't.
The Is used by Solr when parsing queries to
identify which field name should be searched in queries where an
explicit field name has not been used.
But also consider this:
The is used by Solr when parsing queries to
identify which field name should be searched in queries where an
explicit field name has not been used. It is preferable to not use or
rely on this setting; instead the request handler or query LocalParams
for a search should specify the default field(s) to search on. This
setting here can be omitted and it is being considered for
deprecation.
Do you have any data in your instance. try q=*:* and see what it returns. "for" is a stop word, may be it was filtered out. Look for something else as value to test.

Lucene OR query not working

I am trying to query Solr with following requirement:
_ I would like to get all documents which not have a particular field
-exclusivity:[* TO *]
I would like to get all document which have this field and got the specific value
exclusivity:(None)
so when I am trying to query Solr 4 with:
fq=(-exclusivity:[* TO *]) OR exclusivity:(None)
I have only got results if the field exists in document and the value is None but results not contain results from first query !!
I cannot understand why it is not working
To explain your results, the query (-exclusivity:[* TO *]) will always get no results, because you haven't specified any result to retrieve. By default, Lucene doesn't retrieve any results, unless you tell it to get them. exclusivity:(None) isn't a limitation placed on the full result set, it is the key used to find the documents to retrieve. This differs from a database, which by default returns all records in a table, and allows you to limit the set.
(-exclusivity:[* TO *]) only specifies what NOT to get, but doesn't tell it to GET anything at all.
Solr has logic to handle Pure negative queries (I believe, in much the same way as below, by implicitly retrieving all documents first), but from what I gather, only as the top level query, and it does not handle queries like term1 OR -term2 documented here.
I believe with solr you should be able to use the query *:* to get all docs (though that would not be available in raw lucene), so you could use the query:
(*:* -exclusivity:[* TO *]) exclusivity:(None)
which would mean, get (all docs except those with a value in exclusivity) or docs where exclusivity = "None"
I have founded answer to this problem. I have made bad assumption how "-" works in solr.I though that
-exclusivity:[* TO *]
add everything without exclusivity field to the data set but it is not the case. The '-' could only exclude things from data set. BTW femtoRgon you are right but I am using it as fq (filter query) not as a master query I have forgotten to mention that.
So the solution is like
-exclusivity:([* TO *] AND -(None))
and full query looks like
/?q=*:*&fq=-exclusivity:([* TO *] AND -(None))
so that means I will get everything does not have field exclusivity or has this field and it is populated with value None.

Solr query looking for IN, IT, or IS in field

When performing these queries (separately):
country:IN
-or-
country:IT
-or-
country:IS
... I get all items in the index returned. I want to get only the items whose country field matches those params. I've tried every combination of escaping with single/double quotes and single/double slashes. When doing so, no items are returned at all.
I've verified that items exist in the index for these params by dumping the whole index (with a loose query) and identifying them. I'm on django-haystack in case that matters, but the issue is there for both the Django python shell and the Solr web admin interfaces.
Thanks for any help!
Filter queries return a subset of documents that match them.
fq=country:(IN OR IT OR IS)
fq=country:IN
Those are standard noise / stop words. You can either remove the terms from the stopwords file (stopwords_en.txt) and redindex your documents. Or set the type to string and use fq like aitchnyu mentions above.

Resources