You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by PeterKerk <ve...@hotmail.com> on 2014/01/09 19:44:34 UTC

Return only distinct combinations of 2 field values

I'm searching on cities and returning city and province, some cities exist in
different provinces, which is ok.
However, I have some duplicates, meaning 2 cities occur in the same
province. In that case I only want to return 1 result.
I therefore need to have a distinct and unique city+province combination.

How can I make sure that only unique city+province combinations are returned
by my query?

http://localhost:8983/solr/tt-cities/select/?indent=off&facet=false&fl=id,title,provincetitle_nl&q=*:*&defType=lucene&start=0&rows=15

The respective fields are title and provincetitle_nl. Below my schema.xml

    <fieldType name="text_lower_exact" class="solr.TextField"
positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords_dutch.txt"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords_dutch.txt"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
    </fieldType>	

<field name="title" type="text_lower_exact" indexed="true" stored="true"/>
<field name="provincetitle_nl" type="string" indexed="true" stored="true"/>




--
View this message in context: http://lucene.472066.n3.nabble.com/Return-only-distinct-combinations-of-2-field-values-tp4110521.html
Sent from the Solr - User mailing list archive at Nabble.com.