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-12-03 17:32:05 +0300
committerdaita <maxence@pontapreta.net>2016-12-03 17:32:05 +0300
commit7db2f9ff58729faeebcdf60967028986cf5fa47c (patch)
treee7ab99d44ca875b5fd02781f6f86d4a6f1cc45dd
parent8acba3b90a1bf6b122a8bd9b00f31cf1efb72e4e (diff)
0.10.40.10.4
-rw-r--r--CHANGELOG.md4
-rw-r--r--appinfo/info.xml2
-rw-r--r--lib/Service/SolrAdminService.php142
-rw-r--r--lib/Service/SolrService.php4
4 files changed, 136 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b574ab..797f45b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
-**v0.10.3**
+**v0.10.4**
- Upload/creating a .noindex file in a folder will prevent nextant to index its content (and subdirectories)
- --background will force the scan on next tick of the cron
+- Live Index can use database instead of Semaphore
+- bugfixes
**v0.10.2**
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 1913ba5..a24f707 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -40,7 +40,7 @@
</description>
- <version>0.10.3</version>
+ <version>0.10.4</version>
<licence>agpl</licence>
<author>Maxence Lange</author>
<types>
diff --git a/lib/Service/SolrAdminService.php b/lib/Service/SolrAdminService.php
index d3c6930..50b6d55 100644
--- a/lib/Service/SolrAdminService.php
+++ b/lib/Service/SolrAdminService.php
@@ -89,7 +89,12 @@ class SolrAdminService
$changed = false;
while (true) {
foreach ($fields as $field) {
- $this->solrService->message(' * Checking ' . $field['type'] . ' \'' . $field['data']['name'] . '\' : ', false);
+
+ if ($field['type'] === 'copy-field')
+ $this->solrService->message(' * Checking ' . $field['type'] . ' \'' . $field['data']['source'] . '/' . $field['data']['dest'] . '\' : ', false);
+ else
+ $this->solrService->message(' * Checking ' . $field['type'] . ' \'' . $field['data']['name'] . '\' : ', false);
+
if (self::checkFieldProperty($client, $field, $curr, $ierror))
$this->solrService->message('<info>ok</info>');
else {
@@ -100,7 +105,10 @@ class SolrAdminService
if ($fix) {
$changed = true;
- $this->solrService->message(' -> <comment>Fixing ' . $field['type'] . ' \'' . $field['data']['name'] . '\'</comment> ', false);
+ if ($field['type'] === 'copy-field')
+ $this->solrService->message(' -> <comment>Fixing ' . $field['type'] . ' \'' . $field['data']['source'] . '/' . $field['data']['dest'] . '\'</comment> ', false);
+ else
+ $this->solrService->message(' -> <comment>Fixing ' . $field['type'] . ' \'' . $field['data']['name'] . '\'</comment> ', false);
if ($curr) {
if (! self::modifyField($client, $field, $ierror))
@@ -128,7 +136,7 @@ class SolrAdminService
break;
}
-
+ return;
$this->solrService->message('');
$this->solrService->message('Cleaning extra fields');
$currSchema = self::getCurrentSchema($client, $ierror);
@@ -297,7 +305,8 @@ class SolrAdminService
*/
private static function checkFieldProperty(\Solarium\Client $client, $field, &$property, &$ierror)
{
- $property = self::getFieldProperty($client, $field['type'], $field['data']['name'], $ierror);
+ $property = self::getFieldProperty($client, $field, $ierror);
+
if (! $property)
return false;
@@ -362,17 +371,19 @@ class SolrAdminService
* @param string $fieldName
* @return boolean|mixed
*/
- private static function getFieldProperty(\Solarium\Client $client, $fieldType, $fieldName, &$ierror = '')
+ private static function getFieldProperty(\Solarium\Client $client, $field, &$ierror = '')
{
$url = '';
- if ($fieldType == 'field')
+ if ($field['type'] == 'field')
$url = 'schema/fields/';
- if ($fieldType == 'dynamic-field')
+ if ($field['type'] == 'dynamic-field')
$url = 'schema/dynamicfields/';
- if ($fieldType == 'field-type')
+ if ($field['type'] == 'field-type')
$url = 'schema/fieldtypes/';
- if ($fieldType == 'copy-field')
- $url = 'schema/copyfields/';
+ if ($field['type'] == 'copy-field')
+ return self::getCopyFieldProperty($client, $field, $ierror);
+
+ // $url = 'schema/copyfields/';
if ($url == '')
return false;
@@ -380,7 +391,7 @@ class SolrAdminService
$query = $client->createSelect();
$request = $client->createRequest($query);
- $request->setHandler($url . $fieldName);
+ $request->setHandler($url . $field['data']['name']);
$response = $client->executeRequest($request);
if ($response->getStatusCode() != 200)
@@ -409,6 +420,41 @@ class SolrAdminService
}
/**
+ * Get properties on a field based on its type and name
+ *
+ * @param \Solarium\Client $client
+ * @param string $fieldType
+ * @param string $fieldName
+ * @return boolean|mixed
+ */
+ private static function getCopyFieldProperty(\Solarium\Client $client, $field, &$ierror = '')
+ {
+ $url = '';
+ if ($field['type'] != 'copy-field')
+ return false;
+
+ // $url = 'schema/copyfields/';
+
+ $curr = self::getCurrentSchema($client, $ierror);
+ if (! key_exists('copyFields', $curr['schema']))
+ return false;
+
+ $currCopyFields = $curr['schema']['copyFields'];
+
+ $app = new \OCA\Nextant\AppInfo\Application();
+ $app->getContainer()
+ ->query('MiscService')
+ ->log('___' . var_export($field, true) . '---' . var_export($currCopyFields, true));
+
+ foreach ($currCopyFields as $copyfield) {
+ if ($copyfield['dest'] === $field['data']['dest'])
+ return json_decode(json_encode($copyfield), true);
+ }
+
+ return false;
+ }
+
+ /**
* create field on the Solr Core
*
* @param \Solarium\Client $client
@@ -833,9 +879,54 @@ class SolrAdminService
'class' => 'solr.ASCIIFoldingFilterFactory'
),
array(
+ 'class' => 'solr.NGramFilterFactory',
+ 'maxGramSize' => '20',
+ 'minGramSize' => '3'
+ )
+ )
+ ),
+ 'queryAnalyzer' => array(
+ 'tokenizer' => array(
+ 'class' => 'solr.StandardTokenizerFactory'
+ ),
+ 'filters' => array(
+ array(
+ 'class' => 'solr.StandardFilterFactory'
+ ),
+ array(
+ 'class' => 'solr.LowerCaseFilterFactory'
+ ),
+ array(
+ 'class' => 'solr.ASCIIFoldingFilterFactory'
+ )
+ )
+ )
+ )
+ ));
+
+ array_push($fields, array(
+ 'type' => 'field-type',
+ 'data' => array(
+ 'name' => 'text_general_edge',
+ 'class' => 'solr.TextField',
+ 'omitNorms' => false,
+ 'indexAnalyzer' => array(
+ 'tokenizer' => array(
+ 'class' => 'solr.StandardTokenizerFactory'
+ ),
+ 'filters' => array(
+ array(
+ 'class' => 'solr.StandardFilterFactory'
+ ),
+ array(
+ 'class' => 'solr.LowerCaseFilterFactory'
+ ),
+ array(
+ 'class' => 'solr.ASCIIFoldingFilterFactory'
+ ),
+ array(
'class' => 'solr.EdgeNGramFilterFactory',
- // 'class' => 'solr.NGramFilterFactory',
- 'maxGramSize' => '15',
+ 'maxGramSize' => '20',
'minGramSize' => '3'
)
)
@@ -900,6 +991,18 @@ class SolrAdminService
array_push($fields, array(
'type' => 'field',
'data' => array(
+ 'name' => 'text_edge',
+ 'type' => 'text_general_edge',
+ 'indexed' => true,
+ 'stored' => false,
+ 'multiValued' => false
+ )
+ ));
+
+ // text
+ array_push($fields, array(
+ 'type' => 'field',
+ 'data' => array(
'name' => 'text_light',
'type' => 'text_general',
'indexed' => true,
@@ -1069,6 +1172,19 @@ class SolrAdminService
)
));
+ //
+ // copy-field
+ //
+
+ // copy-field
+ array_push($fields, array(
+ 'type' => 'copy-field',
+ 'data' => array(
+ 'source' => 'text',
+ 'dest' => 'text_edge'
+ )
+ ));
+
return $fields;
}
}
diff --git a/lib/Service/SolrService.php b/lib/Service/SolrService.php
index b7433df..82e9f80 100644
--- a/lib/Service/SolrService.php
+++ b/lib/Service/SolrService.php
@@ -510,7 +510,9 @@ class SolrService
if (substr($qstr, 0, 1) == '"')
$value = 150;
- $q .= '(' . $oper . 'text:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^' . $value . ') OR (' . $oper . 'text_light:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^' . $value . ')';
+ $q .= '(' . $oper . 'text:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^' . $value . ')';
+ $q .= ' OR (' . $oper . 'text_light:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^' . $value . ')';
+ $q .= ' OR (' . $oper . 'text_edge:"' . $helper->escapeTerm(str_replace('"', '', $qstr)) . '"^' . ($value * 3) . ')';
}
if ($path !== '')