And I'm not even sure what the actual use case is here. I mean, the values of an enum field must be defined in advance, so if you think a value starts with "H", just eyeball that static list and see that the only predefined value starting with "H" is "High", so you can simply replace your "*" with "igh" - problem solved! Right? Or is there something or a lot more to your use case that you haven't disclosed?

That said, there might be some value to having Solr do the wildcard lookup in the predefined list of values and then search for that value. Although the wildcard or regex could match more than one predefined value, which might be nice to select a set of enum values on a query, an OR of enum values. But... we need to consider the real use case before knowing if this makes any sense. I can imagine interesting use cases, but my personal imagination is not at issue for this particular thread.

-- Jack Krupansky

-----Original Message----- From: Shawn Heisey
Sent: Thursday, May 29, 2014 9:46 AM
To: solr-user@lucene.apache.org
Subject: Re: wildcard matches in EnumField - what do I need to change in code to enable wildcard matches?

On 5/29/2014 12:50 AM, Elran Dvir wrote:
In my index, I have an EnumField called severity. This is its configuration in enumsConfig.xml:

<enum name="severity">
<value>Not Available</value>
<value>Low</value>
<value>Medium</value>
<value>High</value>
<value>Critical</value>
 </enum>

My index contains documents with these values.
When I search for severity:High, I get results. But when I search for severity:H* , I get no results. What do I need to change in Solr code to enable wildcard matches in EnumField (or any other field)?

I would suspect that enum fields are not actually stored as text.  They
are likely stored in the index as an integer, with the Solr schema being
the piece that knows what the strings are for each of the numbers.  I
don't think a wildcard match is possible.

Looking at the code for the EnumFieldValue class (added by SOLR-5084), I
do not see any way to match the string value based on a wildcard or
substring.

If you want to use wildcard matches, you'll need to switch the field to
StrField or TextField, and make sure that all of your code is strict
about the values that can end up in the field.

Thanks,
Shawn

Reply via email to