How to use regex for quering in Solr 4 -
i've reached point of desperation, i'm asking help.
i'm trying query results solr 4 engine using regex.
let's asume document want query is:
<str name="text">description: best company; name: roca mola</str>
and want query using regex:
description:(.*)?company(.*)?;
i read in forums using regex in solr 4 easy adding slashes, like:
localhost:8080/solr/q=text:/description\:(.*)?company(.*)?;/
but isn't working. , 1 doesn't work either:
localhost:8080/solr/q=text:/description(.*)?company(.*)?;/
i don't want simple query like:
localhost:8080/solr/q=text:*company*
since mismatch documents like:
<str name="text">description: home; name: mother company"</str>
if i'm not clear please allow me know.
cheers republic of chile :d
note: using text_general
fields on scheme. @arun pointed out, string
fields can handle type of regex i'm using.
instead of trying regex search on text
field type, seek on string
field type, since regex spanning more 1 word. (if regex needs match single word, can utilize text
field.)
also percent encoding of special characters create sure not cause mismatches.
q=strfield:/description%3a(.*?)company(.*?)%3b.*/
update: tried on string field. above regex works. works without percent encoding i.e.
q=strfield:/description:.*?company.*?;.*/
regex solr
No comments:
Post a Comment