Skip to content

Commit

Permalink
Elevation: Change field name to text worked for elevation
Browse files Browse the repository at this point in the history
  • Loading branch information
ssmarco authored and marczhermo committed Jun 3, 2019
1 parent ce418ba commit 4633142
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
10 changes: 5 additions & 5 deletions Solr/5/extras/elevate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

<elevate>
<query text="foo bar">
<doc id="1"/>
<doc id="2"/>
<doc id="3"/>
<doc id="Page-1"/>
<doc id="Page-2"/>
<doc id="Page-3"/>
</query>

<query text="ipod">
<doc id="MA147LL/A"/> <!-- put the actual ipod at the top -->
<doc id="IW-02" exclude="true"/> <!-- exclude this cable -->
<doc id="Page-3"/> <!-- put Page with ID = 3 at the top -->
<doc id="Page-2" exclude="true"/> <!-- exclude Page ID 2 -->
</query>

</elevate>
16 changes: 8 additions & 8 deletions Solr/5/extras/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">_text</str>
<str name="df">text</str>
</lst>
<!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of
Expand Down Expand Up @@ -876,7 +876,7 @@
<str name="echoParams">explicit</str>
<str name="wt">json</str>
<str name="indent">true</str>
<str name="df">_text</str>
<str name="df">text</str>
</lst>
</requestHandler>

Expand Down Expand Up @@ -918,7 +918,7 @@
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
</str>
<str name="df">_text</str>
<str name="df">text</str>
<str name="mm">100%</str>
<str name="q.alt">*:*</str>
<str name="rows">10</str>
Expand Down Expand Up @@ -1258,7 +1258,7 @@
<!-- a spellchecker built from a field of the main index -->
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">_text</str>
<str name="field">text</str>
<str name="classname">solr.DirectSolrSpellChecker</str>
<!-- the spellcheck distance measure used, the default is the internal levenshtein -->
<str name="distanceMeasure">internal</str>
Expand Down Expand Up @@ -1307,7 +1307,7 @@
<lst name="spellchecker">
<str name="name">wordbreak</str>
<str name="classname">solr.WordBreakSolrSpellChecker</str>
<str name="field">_text</str>
<str name="field">text</str>
<str name="combineWords">true</str>
<str name="breakWords">true</str>
<int name="maxChanges">10</int>
Expand Down Expand Up @@ -1367,7 +1367,7 @@
-->
<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">_text</str>
<str name="df">text</str>
<!-- Solr will use suggestions from both the 'default' spellchecker
and from the 'wordbreak' spellchecker and combine them.
collations (re-written queries) can include a combination of
Expand Down Expand Up @@ -1404,7 +1404,7 @@
-->
<requestHandler name="/tvrh" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">_text</str>
<str name="df">text</str>
<bool name="tv">true</bool>
</lst>
<arr name="last-components">
Expand Down Expand Up @@ -1551,7 +1551,7 @@
-->
<searchComponent name="elevator" class="solr.QueryElevationComponent">
<!-- pick a fieldType to analyze queries -->
<str name="queryFieldType">string</str>
<str name="queryFieldType">text</str>
<str name="config-file">elevate.xml</str>
</searchComponent>

Expand Down
8 changes: 3 additions & 5 deletions Solr/5/templates/schema.ss
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

<fields>
<%-- Default fields, needed for all items --%>
<field name='_documentid' type='string' indexed='true' stored='true' required='true'/>
<field name='ID' type='tint' indexed='true' stored='true' required='true'/>
<field name='id' type='string' indexed='true' stored='true' required='true' multiValued='false'/>
<field name='ID' type='tint' indexed='true' stored='true' required='true' multiValued='false'/>
<field name='ClassName' type='string' indexed='true' stored='true' required='true'/>
<field name='ClassHierarchy' type='string' indexed='true' stored='true' required='true' multiValued='true'/>
<field name='ViewStatus' type='string' indexed='true' stored='true' required='true' multiValued='true'/>
Expand All @@ -62,19 +62,17 @@
<% loop $FulltextFieldDefinitions %>
<field name='$Field' type='$Type' indexed='$Indexed' stored='$Stored' multiValued='$MultiValued'/>
<% end_loop %>

<% loop $FilterFieldDefinitions %>
<field name='$Field' type='$Type' indexed='$Indexed' stored='$Stored' multiValued='$MultiValued'/>
<% end_loop %>

<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
</fields>

<% loop $CopyFieldDefinitions %>
<copyField source='$Field' dest='$Destination'/>
<% end_loop %>

<uniqueKey>_documentid</uniqueKey>
<uniqueKey>id</uniqueKey>

<df>$DefaultField</df>

Expand Down
4 changes: 2 additions & 2 deletions src/Factories/DocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function buildItems($class, $fields, $index, $update, $group, &$count = 0
*/
protected function addDefaultFields(Document $doc, DataObject $item)
{
$doc->setKey('_documentid', $item->ClassName . '-' . $item->ID);
$doc->setKey('id', $item->ClassName . '-' . $item->ID);
$doc->addField('ID', $item->ID);
$doc->addField('ClassName', $item->ClassName);
$doc->addField('ClassHierarchy', ClassInfo::ancestry($item));
Expand All @@ -110,7 +110,7 @@ protected function addDefaultFields(Document $doc, DataObject $item)
protected function addField($doc, $object, $field)
{
$typeMap = Statics::getTypeMap();
if (!$this->classIs(ClassInfo::shortName($object), $field['origin'])) {
if (!$this->classIs(ClassInfo::shortName($object), $field['class'])) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Indexes/BaseIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ abstract class BaseIndex
* @var array
*/
protected $copyFields = [
'_text' => [
'text' => [
'*'
],
];

/**
* @var string
*/
protected $defaultField = '_text';
protected $defaultField = 'text';

/**
* @var SchemaService
Expand Down

0 comments on commit 4633142

Please sign in to comment.