Solr search not giving proper result when search for special character - solr

I am trying to search field which has "\r\n" both together in the field.
I tried this query but it did not work:
fq
Field:"*\r\n*"
But this gives result along with field has "\" only. I just want result for which field contains whole "\r\n".

Related

Is it possible to use multiple words in a filter query in SOLRJ / SOLR?

I am using SOLRJ (with SOLR 7) and my index features some fields for the document contents named content_eng, content_ita, ...
It also features a field with the full path to the document (processed by a StandardTokenizer and a WordDelimiterGraphFilter).
The user is able to search in the content_xyz fields thanks to the lines :
final SolrQuery query = new SolrQuery();
query.setQuery(searchedText);
query.set("qf",searchFields); // searchFields is a generated String which looks like "content_eng content_ita" (field names separated by space)
Now the user needs to be able to specify some words contained in the path (namely some subdirectories). So I added a filterQuery :
query.addFilterQuery(
"full_path_split:" + searchedPath);
If searchedPath contains only a single word contained in the document path, the document is correctly returned however if searchedPath has several words contained in the path, the document is not returned. To sum it up the fq only works if searchedPath contains a single word.
For example doc1 is in /home/user/dir1/doc1.txt
If I search for all (* in searchedText) documents that are in user dir (fq=full_path_split%3Adir) doc1.txt is returned.
If I do the same search but for documents that are in user and dir1 (fq=full_path_split%3user+dir1) doc1.txt is not returned, and I think it is because the fq is parsed as "+full_path_split:user +text:dir1" as debug=query shows. I don't know where text comes from it may be a default field.
So is it possible to use a filter query with several words to fulfill my needs ?
Any help appreciated,
Your suspicion is correct - the _text_:dir1 part comes from you not providing a field name, and the default field name being used instead.
You can work around this by using the more general edismax (or the older dismax) parser as you're doing in your main query with qf:
fq={!type=edismax qf='full_path_split'}user dir1

Inconsistent results in solr when query contains special characters

I am trying to solr search on some log files which are already indexed using solrJ. I want to be able to search a string and the result is the name of the files which contain that particular string.
But if I use special characters the search results are inconsistent. I have admin#10.x.x.x in my log file. If I search admin, I get proper results. If I search admin# then also I get proper results. But if I search admin#10 then I am getting no results. And if I search some string like *a# then I get some results which doesn't even have that string.
I tried escaping metacharacters. That did not work.
I cannot show any code because it is related to my office work.
Note: By results I mean names of log files which contain that particular string. (Not that the filename itself contains the string. That particular file(s) contents contain that search string)

Getting unexpected output in SOLR facet.pivot grouping

I am trying to group the fields in Solr using facet.pivot option. Its working as expected when there is no special character in actual data. In case if any special characters are in actual data then the output is getting split into many.
below is the url I am trying to group using facet.pivot.here escalation_dl is the email address which has some special characters
/select?facet=true&facet.limit=-1&facet.pivot=job_name,escalation_dl&q=*:*
Actual Output:
"field":"job_name",
"value":"test_job1",
"count":1,
"pivot":[{
"field":"escalation_dl",
"value":"test",
"count":1},
{
"field":"escalation_dl",
"value":"gmail.com",
"count":1}]}
Expected Output
"field":"job_name",
"value":"test_job1",
"count":1,
"pivot":[{
"field":"escalation_dl",
"value":"test#gmail.com",
"count":1}]}
This is because the field you're faceting on has a field type with a Tokenizer and filters attached (such as the default text_general field). Use a string field for any field you want to facet on, as that will keep the values intact as you expect.

Solr does not retrieve results for partial string match in shards

In Solr i have 3 cores :
Unicore
Core_1
Core_2
Unicoreis the common core which has all the fields in Core_1 & Core_2
Im getting results for the below query for the string "50000912"
http://localhost:8983/solr/UniCore/select?q=*text:"50000912"*&wt=json&indent=true&shards=http://localhost:8983/solr/Core_1,http://localhost:8983/solr/Core_2
output :
"response":{"numFound":4,"start":0,"maxScore":10.04167,"docs":[
but if i pass "5000091" instead of "50000912" by removing "2" at the end of the string i get zero results
output :
"response":{"numFound":0,"start":0,"maxScore":0.0,"docs":[]
with the same query used which should return more results technically,am i missing some thing or its a bug ? can any one please correct me..
just for the reference this is one my resulting data from Core_2
"response":{"numFound":4,"start":0,"maxScore":10.04167,"docs":[
{
"Storageloc_For_EP":"2500",
"Material_Number":"50000912-001",
"Maximum_LotSize":"0",
"Totrepl_Leadtime":"3",
"Prodstor_Location":"2000",
"Country_Of_Origin":"CN",
"Planned_Deliv_Time":"1",
"Planning_Time_Fence":"0",
"Plant":"5515",
"GR_Processing_Time":"1",
"Minimum_LotSize":"7920",
"Rounding_Value":"720",
"Service_Level_Days":"0",
"id":"2716447",
"Fixed_LotSize":"0",
"Procurement_Type":"F",
"Automatic_PO":"X",
"SchedMargin_Key":"005",
"Service_Level_Qty":"0",
"MRP_Type":"ZB",
"Profit_Center":"B2019",
"_version_":1531317575416283139,
"[shard]":"http://localhost:8983/solr/Core_2",
"score":10.04167},
{
Solr won't do any substring matches unless you've used a NgramFilter (which will generate multiple tokens for each substring of your original token).
My guess is you've indexed the content to a standard defined text field, which means that it'll tokenize on -. That means that what's being stored in the index for that document for Material_Number is 50000912 and 001. Solr will only give hits when both the query and index side tokens match.
You have a few options - you can either add a EdgeNGramFilter which will generate separate tokens for each combination of characters from the start of the string, or since this is a numeric value, you can use a string field (and not a tokenized field, unless it uses the KeywordTokenizer) and a wildcard at the end: q=Material_Number:5000091* will give you any document which have a token that starts with 5000091.

Solr comma separated field - facet search

I got a field in my solr index which holds comma separated values like "area1,area2,area3,area4". There are documents in it where the value is just one value like "area6".
Now i want to make a facet search over all this values.
Example (This is what i want):
area1:10
area2:4297
area3:54
area4:65
area6:87
This is what i get
area1,area2,area3,area4: 7462
area6: 87
Does solr delivers any solutions for this problem or must i seperate the different values on my own.
While indexing you need to get tokens out of the data using ,. You can use the PatternTokenizerFactory tokenizer with , as the pattern. This would split your text whenever it finds a ,.
The field in your schema.xml should be multivalued.

Resources