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
Model: Elevation and Items
  • Loading branch information
ssmarco committed Sep 13, 2019
1 parent 88baa53 commit 8e3dacc
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 15 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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"silverstripe/queuedjobs": "^4",
"solarium/solarium": "^5.0",
"minimalcode/search": "^1.0",
"guzzlehttp/guzzle": "^6.3"
"guzzlehttp/guzzle": "^6.3",
"symbiote/silverstripe-gridfieldextensions": "^3"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
Expand Down
27 changes: 26 additions & 1 deletion src/Admins/SearchAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
namespace Firesphere\SolrSearch\Admins;

use Firesphere\SolrSearch\Models\DirtyClass;
use Firesphere\SolrSearch\Models\ElevatedItem;
use Firesphere\SolrSearch\Models\Elevation;
use Firesphere\SolrSearch\Models\SolrLog;
use SilverStripe\Admin\ModelAdmin;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\View\Requirements;
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;

/**
* Class \Firesphere\SolrSearch\Admins\SearchAdmin
Expand All @@ -24,6 +28,8 @@ class SearchAdmin extends ModelAdmin
private static $managed_models = [
SolrLog::class,
DirtyClass::class,
Elevation::class,
ElevatedItem::class,
];

/**
Expand Down Expand Up @@ -54,6 +60,25 @@ public function init()
{
parent::init();

Requirements::css('firesphere/solr-search:client/dist/main.css');
//Requirements::css('firesphere/solr-search:client/dist/main.css');
}

public function getEditForm($id = null, $fields = null)
{
$oldImportFrom = $this->showImportForm;
$this->showImportForm = false;
/** @var GridField $gridField */
$form = parent::getEditForm($id, $fields);
$this->showImportForm = $oldImportFrom;

if ($this->modelClass === ElevatedItem::class) {
$gridField = $form->Fields()->dataFieldByName($this->sanitiseClassName($this->modelClass));

$gridField
->getConfig()
->addComponent(new GridFieldOrderableRows('Rank'));
}

return $form;
}
}
27 changes: 27 additions & 0 deletions src/Models/ElevatedItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Firesphere\SolrSearch\Models;

use SilverStripe\ORM\DataObject;

class ElevatedItem extends DataObject
{
private static $table_name = 'ElevatedItem';

private static $db = [
'Rank' => 'Int',
'SolrID' => 'Varchar(255)',
'Include' => 'Boolean(1)',
'Exclude' => 'Boolean(0)',
];

private static $has_one = [
'Record' => DataObject::class,
];

private static $belongs_many_many = [
'Keywords' => Elevation::class,
];

private static $summary_fields = ['ID', 'Rank', 'SolrID', 'Include', 'Exclude'];
}
21 changes: 21 additions & 0 deletions src/Models/Elevation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Firesphere\SolrSearch\Models;

use SilverStripe\ORM\DataObject;

class Elevation extends DataObject
{
private static $table_name = 'Elevation';

private static $db = [
'Keyword' => 'Varchar(255)',
];

private static $many_many = [
'Items' => ElevatedItem::class,
];

private static $summary_fields = ['ID', 'Keyword'];
}

0 comments on commit 8e3dacc

Please sign in to comment.