Browse Source

add index settings support

main
ghost 1 year ago
parent
commit
192e45103d
  1. 17
      example/config.json
  2. 6
      src/cli/document/add.php
  3. 8
      src/cli/document/crawl.php
  4. 2
      src/cli/document/search.php
  5. 16
      src/cli/index/init.php
  6. 2
      src/cli/yggo/import.php
  7. 2
      src/webui/index.php
  8. 4
      src/webui/search.php

17
example/config.json

@ -8,7 +8,22 @@ @@ -8,7 +8,22 @@
},
"index":
{
"document":"yo_document"
"document":{
"name":"yo_document",
"settings":
{
"morphology":
[
"stem_cz",
"stem_ar",
"stem_enru"
],
"index_exact_words":1,
"html_strip":1,
"min_word_len":3,
"min_prefix_len":3
}
}
}
},
"webui":

6
src/cli/document/add.php

@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client( @@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client(
// Init index
$index = $client->index(
$config->manticore->index->document
$config->manticore->index->document->name
);
// Check URL for exist
@ -33,7 +33,7 @@ if ($result->getTotal()) @@ -33,7 +33,7 @@ if ($result->getTotal())
echo sprintf(
'URL "%s" already exists in "%s" index!' . PHP_EOL,
$argv[1],
$config->manticore->index->document
$config->manticore->index->document->name
);
exit;
@ -49,7 +49,7 @@ $result = $index->addDocument( @@ -49,7 +49,7 @@ $result = $index->addDocument(
echo sprintf(
'URL "%s" added to "%s" index: %s' . PHP_EOL,
$argv[1],
$config->manticore->index->document,
$config->manticore->index->document->name,
print_r(
$result,
true

8
src/cli/document/crawl.php

@ -32,7 +32,7 @@ $search = new \Manticoresearch\Search( @@ -32,7 +32,7 @@ $search = new \Manticoresearch\Search(
);
$search->setIndex(
$config->manticore->index->document
$config->manticore->index->document->name
);
$search->match(
@ -51,7 +51,7 @@ $search->limit( @@ -51,7 +51,7 @@ $search->limit(
// Init index
$index = $client->index(
$config->manticore->index->document
$config->manticore->index->document->name
);
// Begin queue
@ -182,7 +182,7 @@ foreach($search->get() as $document) @@ -182,7 +182,7 @@ foreach($search->get() as $document)
echo sprintf(
'index "%s" updated: %s %s' . PHP_EOL,
$config->manticore->index->document,
$config->manticore->index->document->name,
print_r(
$result,
true
@ -268,7 +268,7 @@ foreach($search->get() as $document) @@ -268,7 +268,7 @@ foreach($search->get() as $document)
echo sprintf(
'add "%s" to "%s"' . PHP_EOL,
$url,
$config->manticore->index->document
$config->manticore->index->document->name
);
}
}

2
src/cli/document/search.php

@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client( @@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client(
// Init index
$index = $client->index(
$config->manticore->index->document
$config->manticore->index->document->name
);
// Search

16
src/cli/index/init.php

@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client( @@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client(
// Init index
$index = $client->index(
$config->manticore->index->document
$config->manticore->index->document->name
);
// Request options
@ -34,7 +34,7 @@ if (isset($argv[1])) @@ -34,7 +34,7 @@ if (isset($argv[1]))
echo sprintf(
'index "%s" deleted: %s' . PHP_EOL,
$config->manticore->index->document,
$config->manticore->index->document->name,
print_r(
$result,
true
@ -80,12 +80,22 @@ $result = $index->create( @@ -80,12 +80,22 @@ $result = $index->create(
[
'type' => 'integer'
]
],
[
'index_exact_words' => $config->manticore->index->document->settings->index_exact_words,
'html_strip' => $config->manticore->index->document->settings->html_strip,
'min_word_len' => $config->manticore->index->document->settings->min_word_len,
'min_prefix_len' => $config->manticore->index->document->settings->min_prefix_len,
'morphology' => implode(
',',
$config->manticore->index->document->settings->morphology
)
]
);
echo sprintf(
'index "%s" created: %s' . PHP_EOL,
$config->manticore->index->document,
$config->manticore->index->document->name,
print_r(
$result,
true

2
src/cli/yggo/import.php

@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client( @@ -20,7 +20,7 @@ $client = new \Manticoresearch\Client(
// Init index
$index = $client->index(
$config->manticore->index->document
$config->manticore->index->document->name
);
// Connect Yggo DB

2
src/webui/index.php

@ -34,7 +34,7 @@ $client = new \Manticoresearch\Client( @@ -34,7 +34,7 @@ $client = new \Manticoresearch\Client(
// Init index
$index = $client->index(
$config->manticore->index->document
$config->manticore->index->document->name
);
// Get totals

4
src/webui/search.php

@ -32,7 +32,7 @@ $client = new \Manticoresearch\Client( @@ -32,7 +32,7 @@ $client = new \Manticoresearch\Client(
// Init index
$index = $client->index(
$config->manticore->index->document
$config->manticore->index->document->name
);
// Get totals
@ -120,7 +120,7 @@ if (filter_var($q, FILTER_VALIDATE_URL)) @@ -120,7 +120,7 @@ if (filter_var($q, FILTER_VALIDATE_URL))
$query = '@url "' . $q . '"';
}
if (false === strpos($q, '"'))
elseif (false === strpos($q, '"'))
{
$query = '"' . $q . '"';
}

Loading…
Cancel
Save