Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaita <maxence@pontapreta.net>2016-11-16 18:50:29 +0300
committerdaita <maxence@pontapreta.net>2016-11-16 18:50:29 +0300
commitf0ca210db077f3d1c13ea01e67ebec03dbfba41a (patch)
treea81906756505617b157db5d0abb60e84dc4214e0
parent204491297a0a49ad84d82f12b7db71283beb814c (diff)
parente9ec92025809ca42c34954611d970f8b877613fe (diff)
Merge remote-tracking branch 'refs/remotes/origin/master' into filelist
-rw-r--r--CHANGELOG.md4
-rw-r--r--appinfo/info.xml2
-rw-r--r--appinfo/register_command.php2
-rw-r--r--config/nextant_solrconfig.xml2
-rw-r--r--css/navigate.css4
-rw-r--r--lib/Command/Check.php12
-rw-r--r--lib/Command/Index.php2
-rw-r--r--lib/Items/ItemDocument.php40
-rw-r--r--lib/Service/IndexService.php17
-rw-r--r--lib/Service/SolrService.php49
-rw-r--r--lib/Service/SolrToolsService.php8
11 files changed, 113 insertions, 29 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99e8c71..b80a83b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+**v0.6.6**
+- Minor bugfixes.
+
+
**v0.6.5**
- Optimized Index/Extract/Commit
- complete debug information while indexing
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 5b5f370..98f83d2 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -40,7 +40,7 @@
</description>
- <version>0.6.5</version>
+ <version>0.6.6</version>
<licence>agpl</licence>
<author>Maxence Lange</author>
<types>
diff --git a/appinfo/register_command.php b/appinfo/register_command.php
index f689d0c..21ba034 100644
--- a/appinfo/register_command.php
+++ b/appinfo/register_command.php
@@ -27,7 +27,7 @@
$app = new \OCA\Nextant\AppInfo\Application();
$c = $app->getContainer();
-$application->add(new OCA\Nextant\Command\Check($c->query('SolrService'), $c->query('SolrToolsService'), $c->query('SolrAdminService')));
+$application->add(new OCA\Nextant\Command\Check($c->query('SolrService'), $c->query('SolrToolsService'), $c->query('SolrAdminService'), $c->query('SettingsController')));
$application->add(new OCA\Nextant\Command\Clear($c->query('ConfigService'), $c->query('SolrService'), $c->query('SolrAdminService')));
$application->add(new OCA\Nextant\Command\Index(OC::$server->getUserManager(), $c->query('RootFolder'), $c->query('IndexService'), $c->query('QueueService'), $c->query('SolrService'), $c->query('SolrToolsService'), $c->query('SolrAdminService'), $c->query('ConfigService'), $c->query('FileService'), $c->query('BookmarkService'), $c->query('MiscService')));
$application->add(new OCA\Nextant\Command\Optimize($c->query('ConfigService'), $c->query('SolrService'), $c->query('SolrToolsService')));
diff --git a/config/nextant_solrconfig.xml b/config/nextant_solrconfig.xml
index 3d9eb21..8864910 100644
--- a/config/nextant_solrconfig.xml
+++ b/config/nextant_solrconfig.xml
@@ -4,7 +4,7 @@
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
- <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookupFactory</str>
+ <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str>
<str name="field">text</str>
<str name="buildOnCommit">true</str>
</lst>
diff --git a/css/navigate.css b/css/navigate.css
index 582b14b..99c3829 100644
--- a/css/navigate.css
+++ b/css/navigate.css
@@ -62,14 +62,14 @@ SPAN.nextant_line1 {
SPAN.nextant_line2 {
top: 0px;
font-style: italic;
- font-size: 12px;
+ font-size: 11px;
left: 10px;
color: #9e9e9e;
}
SPAN.nextant_line3 {
font-style: italic;
- font-size: 12px;
+ font-size: 11px;
color: #9e9e9e;
left: 10px;
top: 15px;
diff --git a/lib/Command/Check.php b/lib/Command/Check.php
index 5111727..4896491 100644
--- a/lib/Command/Check.php
+++ b/lib/Command/Check.php
@@ -41,12 +41,15 @@ class Check extends Base
private $solrAdmin;
- public function __construct($solrService, $solrTools, $solrAdmin)
+ private $settingsController;
+
+ public function __construct($solrService, $solrTools, $solrAdmin, $settingsController)
{
parent::__construct();
$this->solrService = $solrService;
$this->solrTools = $solrTools;
$this->solrAdmin = $solrAdmin;
+ $this->settingsController = $settingsController;
}
protected function configure()
@@ -54,6 +57,7 @@ class Check extends Base
parent::configure();
$this->setName('nextant:check')
->setDescription('check, fix and optimise your current Solr configuration')
+ ->addOption('info', 'i', InputOption::VALUE_NONE, 'display some info')
->addOption('fix', 'f', InputOption::VALUE_NONE, 'fix');
}
@@ -64,6 +68,10 @@ class Check extends Base
return;
}
+ if ($input->getOption('info')) {
+ $output->writeln(var_export($this->settingsController->updateSubOptions(true, 'check'), true));
+ }
+
$this->solrService->setOutput($output);
$client = $this->solrService->getClientConfig()['endpoint']['localhost'];
@@ -87,7 +95,7 @@ class Check extends Base
$output->writeln(' - ' . $this->solrTools->count('files') . ' files');
$output->writeln(' - ' . $this->solrTools->count('bookmarks') . ' bookmarks');
- $output->writeln(' - ' . $this->solrTools->getInfoCore()->index->segmentCount . ' segments');
+ $output->writeln(' - ' . $this->solrTools->getInfoCore()->index->segmentCount . ' segments');
}
}
diff --git a/lib/Command/Index.php b/lib/Command/Index.php
index d406091..2f922ed 100644
--- a/lib/Command/Index.php
+++ b/lib/Command/Index.php
@@ -87,7 +87,7 @@ class Index extends Base
parent::configure();
$this->setName('nextant:index')
->setDescription('scan users\' files, generate and index Solr documents')
- ->addOption('debug', 'd', InputOption::VALUE_NONE, 'display more text')
+ ->addOption('debug', 'd', InputOption::VALUE_OPTIONAL, 'display more text')
->addOption('unlock', 'k', InputOption::VALUE_NONE, 'unlock on Solr')
->addOption('force', 'f', InputOption::VALUE_NONE, 'force extract and update of all your documents')
->addOption('user', 'u', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'indexes file of the given user(s)')
diff --git a/lib/Items/ItemDocument.php b/lib/Items/ItemDocument.php
index baeb349..5ebf7ca 100644
--- a/lib/Items/ItemDocument.php
+++ b/lib/Items/ItemDocument.php
@@ -527,9 +527,9 @@ class ItemDocument
return null;
}
- public function toArray()
+ public function toArray($complete = false)
{
- return array(
+ $arr = array(
'entry' => $this->getEntry(),
'data' => array(
'id' => $this->getId(),
@@ -541,6 +541,42 @@ class ItemDocument
'lines' => $this->lines
)
);
+
+ if ($complete)
+ $arr['complete'] = $complete = array(
+ 'type' => $this->getType(),
+ 'source' => $this->getSource(),
+ 'owner' => $this->getOwner(),
+ 'path' => $this->getPath(),
+ 'mimetype' => $this->getMimetype(),
+ 'size' => $this->getSize(),
+ 'absolutepath' => $this->getAbsolutePath(),
+ 'mtime' => $this->getMTime(),
+ 'share' => $this->getShare(),
+ 'sharegroup' => $this->getSharegroup(),
+ 'storage' => array(
+ 'local' => $this->getStorage()->isLocal()
+ ),
+ 'needextract' => $this->neededExtract(),
+ 'needUpdate' => $this->neededUpdate(),
+ 'remote' => $this->isRemote(),
+ 'encrypted' => $this->isEncrypted(),
+ 'extractable' => $this->isExtractable(),
+ 'indexed' => $this->isIndexed(),
+ 'extracted' => $this->isExtracted(),
+ 'processed' => $this->isProcessed(),
+ 'deleted' => $this->isDeleted(),
+ 'removed' => $this->isRemoved(),
+ 'updated' => $this->isUpdated(),
+ 'failedIndex' => $this->isFailedIndex(),
+ 'failedExtract' => $this->isFailedExtract(),
+ 'failedUpdate' => $this->isFailedUpdate(),
+ 'temp' => $this->isTemp(),
+ 'invalid' => $this->isInvalid(),
+ 'synced' => $this->isSynced()
+ );
+
+ return $arr;
}
public function toString()
diff --git a/lib/Service/IndexService.php b/lib/Service/IndexService.php
index a980881..c14ba69 100644
--- a/lib/Service/IndexService.php
+++ b/lib/Service/IndexService.php
@@ -229,6 +229,13 @@ class IndexService
$entry->extractable(true);
}
+ if ($this->output != null && $this->debug == 2) {
+ $this->output->writeln('');
+ $this->output->writeln('### FILE ' . $entry->getPath());
+ $this->output->writeln('_current: ' . var_export($entry->toArray(), true));
+ $this->output->writeln('_solr: ' . var_export(ItemDocument::getItem($solrDocs, $entry), true));
+ }
+
if (! $entry->isExtractable() && $this->configService->getAppValue('index_files_tree') !== '1')
continue;
@@ -238,6 +245,9 @@ class IndexService
if (! $this->force && $this->solrTools->isDocumentUpToDate($entry, ItemDocument::getItem($solrDocs, $entry)))
continue;
+ if ($this->output != null && $this->debug == 2)
+ $this->output->writeln('- Extracting!');
+
if ($progress != null) {
$progress->setMessage('+', 'job');
$progress->setMessage('[extracting]', 'infos');
@@ -253,7 +263,14 @@ class IndexService
$this->solrService->indexDocument($entry, $ierror);
+ if ($this->output != null && $this->debug == 2)
+ $this->output->writeln('- Extracted: ' . (($entry->isFailedExtract()) ? 'n' : 'y') . ' ' . $ierror->getCode() . ' ' . $ierror->getMessage());
+
if ((time() - self::REFRESH_COMMIT) > $this->lastCommitTick) {
+
+ if ($this->output != null && $this->debug == 2)
+ $this->output->writeln('- Commiting!');
+
$progress->setMessage('@', 'job');
$progress->setMessage('[commiting]', 'infos');
$progress->display();
diff --git a/lib/Service/SolrService.php b/lib/Service/SolrService.php
index e04e31d..dd75a59 100644
--- a/lib/Service/SolrService.php
+++ b/lib/Service/SolrService.php
@@ -469,10 +469,8 @@ class SolrService
return false;
}
- $query->setRows(25);
-
- // $query->setQuery('text:' . ((! in_array('complete_words', $options)) ? '*' : '') . $helper->escapePhrase($string));
array_push($options, 'complete_words');
+ // $query->setQuery('text:' . ((! in_array('complete_words', $options)) ? '*' : '') . $helper->escapePhrase($string));
$q = '';
$path = '';
@@ -480,29 +478,29 @@ class SolrService
foreach ($astring as $qstr) {
$oper = '';
- $value = 1;
+ $value = 15;
if (strpos($special, substr($qstr, 0, 1)) !== false) {
$oper = substr($qstr, 0, 1);
$qstr = substr($qstr, 1);
}
- $path .= 'nextant_path:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^10 ' . "\n";
+ $path .= $oper . 'nextant_path:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^30 ' . "\n";
if (substr($qstr, 0, 1) == '"')
- $value *= 30;
+ $value = 150;
$q .= $oper . 'text:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^' . $value . ' ';
}
- $q .= "\n" . $path;
-
- // Uncomment to display the request sent to solr
- // $this->miscService->log($q);
+ if ($path !== '')
+ $q = '(' . $q . ")\n OR (" . $path . ')';
+
+ // Uncomment to display the request sent to solr
+ // $this->miscService->log($q);
+ $query->setRows(25);
$query->setQuery($q);
-
$query->createFilterQuery('owner')->setQuery($ownerQuery);
-
$query->setFields(array(
'id',
'nextant_deleted',
@@ -520,10 +518,14 @@ class SolrService
$hl = $query->getHighlighting();
$hl->setSimplePrefix('<span class="nextant_hl">');
$hl->setSimplePostfix('</span>');
- $hl->setSnippets(3);
+ $hl->setSnippets(5);
+ // $hl->setAlternateField('nextant_path');
+ $hl->setFragSize(70);
+ $hl->setMaxAnalyzedChars(50000000);
$hl->setFields(array(
'text'
));
+ // 'nextant_path'
$resultset = $client->select($query);
$highlighting = $resultset->getHighlighting();
@@ -584,10 +586,14 @@ class SolrService
$t ++;
if ($t == $suggTotal) {
- foreach ($termResult as $result)
- $suggestions[] = array(
- 'suggestion' => '<b>' . $string . '</b>' . (($termResult->getEndOffset() >= strlen($string)) ? substr($result, strlen($term)) : '')
- );
+ foreach ($termResult as $result) {
+ $suggest = '<b>' . $string . '</b>' . (($termResult->getEndOffset() >= strlen($string)) ? substr($result, strlen($term)) : '');
+
+ if (! self::suggestionAlreadyKnown($suggestions, $suggest))
+ $suggestions[] = array(
+ 'suggestion' => $suggest
+ );
+ }
}
}
@@ -653,5 +659,14 @@ class SolrService
} else
$this->lastMessage = $line;
}
+
+ private static function suggestionAlreadyKnown($list, $suggest)
+ {
+ foreach ($list as $item) {
+ if ($item['suggestion'] === $suggest)
+ return true;
+ }
+ return false;
+ }
}
diff --git a/lib/Service/SolrToolsService.php b/lib/Service/SolrToolsService.php
index 201fe0c..7fe790c 100644
--- a/lib/Service/SolrToolsService.php
+++ b/lib/Service/SolrToolsService.php
@@ -423,7 +423,7 @@ class SolrToolsService
* @param ItemError $ierror
* @return boolean|Solarium\Core\Query\Result
*/
- public function getInfoCore(&$ierror = '')
+ public function getInfoCore($complete = false, &$ierror = '')
{
if (! $this->solrService || ! $this->solrService->configured() || ! $this->solrService->getClient()) {
$ierror = new ItemError(SolrService::ERROR_SOLRSERVICE_DOWN);
@@ -434,8 +434,12 @@ class SolrToolsService
$client = $this->solrService->getClient();
$query = $client->createSelect();
- $request = $client->createRequest($query);
+ if (! $complete)
+ $query->setFields(array(
+ 'index'
+ ));
+ $request = $client->createRequest($query);
$request->setHandler('admin/luke');
$response = $client->executeRequest($request);