Search code examples
solrlucenedatastax-enterprise

Undefined name x in selection clause even when x is stored


I'm creating a copied field with color synonyms from a color description field and this is working. I'm able to search using my copied field like this

/solr/my_keyspace.my_table/select?q=color_base:white

But the field is not showing up in the search results and if I add the field to the field list like this

/solr/my_keyspace.my_table/select?q=color_base:white&fl=color_base

I get the error

Undefined name color_base in selection clause

Here is my schema - I thought stored="true" would do the trick but it's not. I just want to see the field color_base in the search results.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schema name="autoSolrSchema" version="1.5">
    <types>
        <fieldType class="org.apache.solr.schema.TextField" name="ColorField">
            <analyzer>
                <tokenizer class="solr.KeywordTokenizerFactory"/>
                <filter class="solr.SynonymFilterFactory" ignoreCase="true" synonyms="color_synonyms.txt" tokenizerFactory="solr.KeywordTokenizerFactory"/>
            </analyzer>
        </fieldType>
        <fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
    </types>
    <fields>
        <field indexed="true" multiValued="false" name="color_description" stored="true" type="StrField" docValues="true"/>
        <field indexed="true" multiValued="true" name="color_base" stored="true" type="ColorField" docValues="true"/>
        <copyField source="color_description" dest="color_base"/>
    </fields>
    <uniqueKey>(year, make, base_model)</uniqueKey>
</schema>

Solution

  • I figured out that I can't add search results using analyzers which was my goal. The analyzers are only for improving the searching capability but results cannot be modified by Solr. I had to add a new field to the underlying db (Cassandra) and map the values I wanted into it. Lesson learned - Solr is for searching ONLY, not for changing/updating/appending result sets.