0

I am new to Solr.

I am trying to search for records containing single round bracket either '(' or ')'.

The query for searching the record is as follows:

q=( ( name: (*\(abc*) ) )

The above query breaks the solr search.

I am escaping the ( ) character by using the following regex:

value = value.replace(/([()])/g, '\\$1');

Can someone please help to troubleshoot this issue ?

Soham Nakhare
  • 425
  • 4
  • 18
  • Basically looking for contains query with parenthesis. – Soham Nakhare Feb 23 '17 at 09:06
  • 1
    What do you mean by "breaks the solr search"? Crash, error, zero hits? The query that @Persimmonium suggests is fine, so your problem might be that your analyzer removes parentheses. Check this by doing a `name:known\)word` search followed by `name:known\)word*`. If the last one doesn't give a hit, your analyzer probably removes `)`. You can also do it through _Analysis_ in the GUI, which will tell you more (and might be more confusing). – Toke Eskildsen Feb 23 '17 at 10:23
  • As I understand from your question, you need only '(' or ')' not both. Following query would serve the purposes `name: *\(* OR name:*\)* NOT name:*\(*\)*` – mjlowky Feb 23 '17 at 11:28

1 Answers1

2

I am not very good with the regex so I cannot discern what is happening there, but this solr query should work:

q=name:*\(abc*

does it no?

As you can see in the lucene doc, the only char to escape in your query is (. ) would need to be escaped too if you search for it. But I understand in your example all the ) are just part of the language.

Persimmonium
  • 15,593
  • 11
  • 47
  • 78