Discussion:
Case insensitive query for fetching facets
Ritesh Kumar
2018-12-06 13:26:30 UTC
Permalink
Hello team,

I am trying to prepare facet on a field of type string. The facet data will
be shown according to the user's query on this very field.

<field name="fieldName" type="string" indexed="true" stored="true"
required="false" multiValued="false"/>


As this field is of type string, it works fine with case sensitive query. I
want to be able to query on this field irrespective of the case.

I tried changing the field type to string_ci as defined below

<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true"
omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

<field name="fieldName" type="string_ci" indexed="true" stored="true"
required="false" multiValued="false"/>

Now, in this case, I am able to perform a case-insensitive query but the
facet values are being shown in lowercase.

I want to be able to perform a case-insensitive query on this field but
show the original data.
Is there anything I can do achieve this.

Best,
--
Ritesh Kumar
Mikhail Khludnev
2018-12-06 13:36:00 UTC
Permalink
Hello, Ritesh.

It's obviously done with copyField.
Post by Ritesh Kumar
Hello team,
I am trying to prepare facet on a field of type string. The facet data will
be shown according to the user's query on this very field.
<field name="fieldName" type="string" indexed="true" stored="true"
required="false" multiValued="false"/>
As this field is of type string, it works fine with case sensitive query. I
want to be able to query on this field irrespective of the case.
I tried changing the field type to string_ci as defined below
<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true"
omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="fieldName" type="string_ci" indexed="true" stored="true"
required="false" multiValued="false"/>
Now, in this case, I am able to perform a case-insensitive query but the
facet values are being shown in lowercase.
I want to be able to perform a case-insensitive query on this field but
show the original data.
Is there anything I can do achieve this.
Best,
--
Ritesh Kumar
--
Sincerely yours
Mikhail Khludnev
Ritesh Kumar
2018-12-07 06:02:59 UTC
Permalink
Yes, it can be used.
But, what if I have other such facets on different other fields. Use of
copyField will require me to create a dedicated copy field for each such
facet.

I want to know if there is any other option where I do not have to add
multiple copy fields.
Post by Mikhail Khludnev
Hello, Ritesh.
It's obviously done with copyField.
On Thu, Dec 6, 2018 at 4:26 PM Ritesh Kumar <
Post by Ritesh Kumar
Hello team,
I am trying to prepare facet on a field of type string. The facet data
will
Post by Ritesh Kumar
be shown according to the user's query on this very field.
<field name="fieldName" type="string" indexed="true" stored="true"
required="false" multiValued="false"/>
As this field is of type string, it works fine with case sensitive
query. I
Post by Ritesh Kumar
want to be able to query on this field irrespective of the case.
I tried changing the field type to string_ci as defined below
<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true"
omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="fieldName" type="string_ci" indexed="true" stored="true"
required="false" multiValued="false"/>
Now, in this case, I am able to perform a case-insensitive query but the
facet values are being shown in lowercase.
I want to be able to perform a case-insensitive query on this field but
show the original data.
Is there anything I can do achieve this.
Best,
--
Ritesh Kumar
--
Sincerely yours
Mikhail Khludnev
Mikhail Khludnev
2018-12-07 07:52:11 UTC
Permalink
Fields need to be copied. You can shorten the schema with using wildcards
*.
Post by Ritesh Kumar
Yes, it can be used.
But, what if I have other such facets on different other fields. Use of
copyField will require me to create a dedicated copy field for each such
facet.
I want to know if there is any other option where I do not have to add
multiple copy fields.
Post by Mikhail Khludnev
Hello, Ritesh.
It's obviously done with copyField.
On Thu, Dec 6, 2018 at 4:26 PM Ritesh Kumar <
Post by Ritesh Kumar
Hello team,
I am trying to prepare facet on a field of type string. The facet data
will
Post by Ritesh Kumar
be shown according to the user's query on this very field.
<field name="fieldName" type="string" indexed="true" stored="true"
required="false" multiValued="false"/>
As this field is of type string, it works fine with case sensitive
query. I
Post by Ritesh Kumar
want to be able to query on this field irrespective of the case.
I tried changing the field type to string_ci as defined below
<fieldType name="string_ci" class="solr.TextField"
sortMissingLast="true"
Post by Mikhail Khludnev
Post by Ritesh Kumar
omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="fieldName" type="string_ci" indexed="true" stored="true"
required="false" multiValued="false"/>
Now, in this case, I am able to perform a case-insensitive query but
the
Post by Mikhail Khludnev
Post by Ritesh Kumar
facet values are being shown in lowercase.
I want to be able to perform a case-insensitive query on this field but
show the original data.
Is there anything I can do achieve this.
Best,
--
Ritesh Kumar
--
Sincerely yours
Mikhail Khludnev
--
Sincerely yours
Mikhail Khludnev
David Hastings
2018-12-07 13:34:33 UTC
Permalink
you could change your indexer to index the values to a dynamic field *_ci
for each of the facets.
ie, your facet is organization. index to the string field, and also index
it to the dynamic organization_ci field
but there will not be a short cut way of doing this in the schema itself
Post by Ritesh Kumar
Yes, it can be used.
But, what if I have other such facets on different other fields. Use of
copyField will require me to create a dedicated copy field for each such
facet.
I want to know if there is any other option where I do not have to add
multiple copy fields.
Post by Mikhail Khludnev
Hello, Ritesh.
It's obviously done with copyField.
On Thu, Dec 6, 2018 at 4:26 PM Ritesh Kumar <
Post by Ritesh Kumar
Hello team,
I am trying to prepare facet on a field of type string. The facet data
will
Post by Ritesh Kumar
be shown according to the user's query on this very field.
<field name="fieldName" type="string" indexed="true" stored="true"
required="false" multiValued="false"/>
As this field is of type string, it works fine with case sensitive
query. I
Post by Ritesh Kumar
want to be able to query on this field irrespective of the case.
I tried changing the field type to string_ci as defined below
<fieldType name="string_ci" class="solr.TextField"
sortMissingLast="true"
Post by Mikhail Khludnev
Post by Ritesh Kumar
omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="fieldName" type="string_ci" indexed="true" stored="true"
required="false" multiValued="false"/>
Now, in this case, I am able to perform a case-insensitive query but
the
Post by Mikhail Khludnev
Post by Ritesh Kumar
facet values are being shown in lowercase.
I want to be able to perform a case-insensitive query on this field but
show the original data.
Is there anything I can do achieve this.
Best,
--
Ritesh Kumar
--
Sincerely yours
Mikhail Khludnev
Alexandre Rafalovitch
2018-12-07 15:15:39 UTC
Permalink
If you are on the latest Solr (7.3+), try switching from TextField to
SortableTextField in your string_ci definition above.

That type implicitly uses docValues and should return original text
for faceting purposes, while still allowing analyzers.

Regards,
Alex.
On Thu, 6 Dec 2018 at 08:26, Ritesh Kumar
Post by Ritesh Kumar
Hello team,
I am trying to prepare facet on a field of type string. The facet data will
be shown according to the user's query on this very field.
<field name="fieldName" type="string" indexed="true" stored="true"
required="false" multiValued="false"/>
As this field is of type string, it works fine with case sensitive query. I
want to be able to query on this field irrespective of the case.
I tried changing the field type to string_ci as defined below
<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true"
omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="fieldName" type="string_ci" indexed="true" stored="true"
required="false" multiValued="false"/>
Now, in this case, I am able to perform a case-insensitive query but the
facet values are being shown in lowercase.
I want to be able to perform a case-insensitive query on this field but
show the original data.
Is there anything I can do achieve this.
Best,
--
Ritesh Kumar
Loading...