Skip to content

Commit

Permalink
Add EdgeNGram indexing on id and full_title_tesim for autocomplete. F…
Browse files Browse the repository at this point in the history
…ixes #293
  • Loading branch information
jcoyne committed Feb 26, 2014
1 parent 3a451b9 commit 00a16d0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
26 changes: 26 additions & 0 deletions solr_conf/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<field name="lng" type="tdouble" stored="true" indexed="true" multiValued="false"/>
<field name="original_pid_tesim" type="pid_text" stored="true" indexed="true" multiValued="true"/>

<field name="full_title_tesim" type="text_en_ng" stored="true" indexed="true" multiValued="true"/>
<field name="id_tesim" type="text_en_ng" stored="true" indexed="true" multiValued="false"/>

<!-- NOTE: not all possible Solr field types are represented in the dynamic fields -->

<!-- text (_t...) -->
Expand Down Expand Up @@ -198,6 +201,7 @@
destination field is to use the dynamic field syntax.
copyField also supports a maxChars to copy setting. -->

<copyField source="id" dest="id_tesim" maxChars="3000"/>
<copyField source="*_tesim" dest="all_text_timv" maxChars="3000"/>

<types>
Expand Down Expand Up @@ -288,6 +292,28 @@
</analyzer>
</fieldType>

<!-- A text field with defaults appropriate for English an NGrams -->
<fieldType name="text_en_ng" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.ICUTokenizerFactory"/>
<filter class="solr.ICUFoldingFilterFactory"/> <!-- NFKC, case folding, diacritics removed -->
<filter class="solr.EnglishPossessiveFilterFactory"/>
<!-- EnglishMinimalStemFilterFactory is less aggressive than PorterStemFilterFactory: -->
<filter class="solr.EnglishMinimalStemFilterFactory"/>
<filter class="solr.TrimFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="15" side="front"/>:
</analyzer>

<analyzer type="index">
<tokenizer class="solr.ICUTokenizerFactory"/>
<filter class="solr.ICUFoldingFilterFactory"/> <!-- NFKC, case folding, diacritics removed -->
<filter class="solr.EnglishPossessiveFilterFactory"/>
<!-- EnglishMinimalStemFilterFactory is less aggressive than PorterStemFilterFactory: -->
<filter class="solr.EnglishMinimalStemFilterFactory"/>
<filter class="solr.TrimFilterFactory"/>
</analyzer>
</fieldType>

<fieldType name="pid_text" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
Expand Down
2 changes: 1 addition & 1 deletion solr_conf/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
http://wiki.apache.org/solr/LocalParams
-->
<str name="qf">
id
id_tesim
full_title_tesim
short_title_tesim
alternative_title_tesim
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/spotlight/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
get :index, exhibit_id: exhibit, q: 'map'
expect(controller.blacklight_config.show.partials.first).to eq "curation_mode_toggle"
end

it "should have partial matches for title" do
get :index, exhibit_id: exhibit, q: 'ZUYDLA'
expect(assigns[:document_list].first.id).to eq 'dx157dh4345'
end
it "should have partial matches for id" do
get :index, exhibit_id: exhibit, q: 'dx157'
expect(assigns[:document_list].first.id).to eq 'dx157dh4345'
end
end
end

Expand Down

0 comments on commit 00a16d0

Please sign in to comment.