If i use At(#) symbol in regular expression based search as explained here http://lucene.apache.org/core/4_2_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description the lucene search treats it as 'any string' and doesn't match the character '#' .. Even escaping with backslash is not working. I'm using cloudant java client.
Is there is a way to use '#' in regular expression search of cloudant lucene search?
It will work if you are using keyword analyzer for that indexed field. But you have to see whether keyword analyzer is the right one for your requirements.
"Data":"TestMe#"
{"q":"Data:/TestMe[#]/"}
Related
I have a query in Elastic Search shown below
sample code
How can I perform the same using Solr?
You can search by query string like given below.
http://domain/solr/core_name/select?q=*:*&fq=studentId:14466&wt=json&indent=true
You can do a single match against a field in standard Lucene syntax:
q=field:value
Having field names with characters outside of [a-zA-Z0-9] isn't recommended, but you could probably escape it properly with student\ I\'d:14466.
I need to do solr search for a string like BEBIL1407-GREEN with special character(-) but it is ignoring - and searches for only with BEBIL1407. I need to search with a hole word.Im using solr_4.5.1
Example Query :
q=BEBIL1407-GREEN&qt=select&start=0&rows=24&fq=clg%3A%222%22&fq=isAproved%3A%22Y%22&fl=id
Your question is about searching for BEBIL1407-GREEN but finding BEBIL1407.
You did not post your schem or your query parser.
As default solr using the standard query parser on field "text" with fieldtype "text_general".
You can test with the solr analysis screen the way from a word (in real text) to the corresponding token in the index.
For "text_general" the word "BEBIL1407-GREEN" goes to two token: "bebil1407" and "green".
The Standard-Parser does support escaping of special characters this would help if your word starts with a hyphen(minus sign). But in this case most possible the tokenizer is the reason of "finding unexpected documents".
Solution:
You can search with a phrase. In this case "BIBIL1407-GREEN" will also find "BIBIL1407 GREEN"
You can use an other FieldType e.g. one with WhiteSpaceTokenizer
Hope this helps, otherwise post your search field and your definition from schema.xml...
There is a field in my schema 'fullText' which is of the 'text_en' type, and multivalued. The term 'tests' is in the fullText field in one document.
In solr, when I try to search using the word 'test', with the standard lucene parser with minimal distance 1, its returning the document. The query I am using is:
http://localhost:8983/solr/simple/select?q=fullText:test~1&wt=xml&indent=true
But I am doing the same using dismax, and its not returning the document. The queries I have tried are:
http://localhost:8983/solr/simple/select?q=test&wt=xml&indent=true&defType=dismax&qf=fullText~1
http://localhost:8983/solr/simple/select?q=test~1&wt=xml&indent=true&defType=dismax&qf=fullText
DisMax, by design, does not support all lucene query syntax in it's query parameter. From the documentation:
This query parser supports an extremely simplified subset of the Lucene QueryParser syntax. Quotes can be used to group phrases, and +/- can be used to denote mandatory and optional clauses ... but all other Lucene query parser special characters are escaped to simplify the user experience.
Fuzzy queries are one of the things that are not supported. There is a request to add it to the qf parameter, if you'd care to take a look, but it has not been implemented.
One good solution would be to go to the edismax query parser, instead. It's query parameter supports full lucene query parser syntax:
http://localhost:8983/solr/simple/select?q=test~1&defType=edismax&qf=fullText
I'm having a problem using the Solr ExtendedDisMax Query Parser with query that contains fielded searches inside not-plain queries.
The case is the following.
If I send to SOLR an edismax request (defType=edismax) with parameters
qf=field1^10
q=field2:ciao
debugQuery=on (for debug purposes)
solr parses the query as I expect, in fact the debug part of the response tells me that
[parsedquery_toString] => +field2:ciao
But if I make the expression only a bit more complex, like putting the condition into brackets:
1. qf=field1^10
2. q=(field2:ciao)
I get
[parsedquery_toString] => +(((field1:field2:^2.0) (field1:ciao^2.0))~2)
where Solr seems not recognize the field syntax.
I've not found any mention to this behavior in the documentation, where instead they say that
This parser supports full Lucene QueryParser syntax including boolean operators 'AND', 'OR', 'NOT', '+' and '-', fielded search, term boosting, fuzzy...
This problem is really annoying me because I would like to do compelx boolean and fielded queries even with the edismax parser.
Do you know a way to workaround this?
EDIT: The Solr version is 3.6
If you are using Solr 3.6, there is a current issue with eDisMax and Fielded searches that was introduced with Solr 3.6. The workaround is to precede the field name with a space.
So change your query to the following:
qf=field1^10
q=( field2:ciao)
Please see eDismax: A fielded query wrapped by parens is not recognized for the more details.
I'm trying to find documents containing asterisks/query marks in Solr text field using Edismax parser. Everything works perfectly when I search for usual text (fq={!edismax}textfield:*sometext*) or even for any other special Lucene character using escaping (fq={!edismax}textfield:*\~*).
However when searching for * (fq={!edismax}textfield:*\**) or ? (fq={!edismax}textfield:*\?*) these characters seem not to be escaped, since all documents are returned. I try also URL encoding for escaped characters (like \%2A instead of \*), however the result is the same.
The problem appear to concern leading wildcards only, since fq={!edismax}textfield:\** and fq={!edismax}textfield:\?* return correct results, but fq={!edismax}textfield:*\* and fq={!edismax}textfield:*\? do not (as well as fq={!edismax}textfield:*sometext\* etc.).
How is it possible to search for */? using Edismax with leading asterisk wildcard?
Quoting the asterisk works for me. This query finds two books in my index with a standalone asterisk in the title:
title:"*"
Here is the title of one of them: "Be * Know * Do, Adapted from the Official Army Leadership Manual".
I'm using a edismax with Solr 3.3.