0

I am using SOLR as a search engine of my application. But now it is not showing proper results.

In my schema file there is column SubscriptionIds which holds multiple values with a separator. They are stored as ,,4588,,4585,,6966,,4855,

Similarly there is another column ABCId which holds a single value SKJJ54855

When i fire a query :

ABCId:(SKJJ54855)

it shows me records which has Subscriptionds with values as ,,4588,,4585,,6966,,4855,

But when i fire a query :

SubscriptionIds: (,4855,) && ABCId:(SKJJ54855)

It doesnt get me result!!!.

One more case, when i fire a query: SubscriptionIds: (,6966,) && ABCId:(SKJJ54855)

It gets me results... for your reference (,6966,) is placed second last in SubscriptionIds list.

Why it is behaving so weird.!!!

Some portion from my Schema.xml file.

    <fieldType name="textgen" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords.txt"
                enablePositionIncrements="true"
                />
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>

<field name="SubscriptionIds" type="textgen" indexed="true" stored="true" />



<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<field name="ABCId" type="string" indexed="true" stored="true"/>
shakti
  • 191
  • 1
  • 8
  • 21
  • Can you please post the relevant sections of your `schema.xml`? – ziad-saab May 28 '12 at 06:42
  • hi zi42, please view my "Some portion from my Schema.xml file." section. I have updated the above question. Thanks – shakti May 28 '12 at 07:47
  • Please check my answer. If you need help for the indexing part, let me know what language/adapter you're using and I'll point you to some code that does what you want for multi-valued fields. – ziad-saab May 28 '12 at 07:52

1 Answers1

2

My suggestion would be to make the field SubscriptionIds multi-valued, and store many IDs separately. This will be more representative of the actual data than a comma-separated list. Change it to:

<field name="SubscriptionIds" type="int" indexed="true" stored="true" multiValued="true" />

and change your indexing code to add multiple IDs to the SubscriptionIds field.

ziad-saab
  • 19,139
  • 3
  • 36
  • 31
  • @zia42, my problem is bit different. at some instances the query SubscriptionIds: (,4855,) && ABCId:(ASEJ54855) but similar query for another ABCId: TYEEW46222 doesnt get me records. eg: SubscriptionIds: (,4855,) && ABCId:(TYEEW46222) doesnt get me any result. But if we just type ABCId: (TYEEW46222) we can see in result that in SubscriptionIds field their is ,4855, as a value. – shakti May 28 '12 at 09:52
  • 1
    I understand. But why go through the convoluted route of storing IDs as a comma-separated list instead of storing the right way? – ziad-saab May 28 '12 at 13:06