teamtnt / tntsearch

A fully featured full text search engine written in PHP
https://tnt.studio/solving-the-search-problem-with-laravel-and-tntsearch
MIT License
3.08k stars 292 forks source link

Some ';' in the example code #63

Closed the94air closed 7 years ago

the94air commented 7 years ago

there are some Embarrassing ; in the example query articles;

$indexer->query('SELECT id, article FROM articles;');
nticaric commented 7 years ago

It's embarrassing not to know that it's perfectly fine to close a SQL statement with a semicolon ;)

the94air commented 7 years ago

Sorry i didn't remember the 'semicolon' eng word. Never mind :smiley: . thanks for the info. but i don't know ???? does only 2 queries make my search fast enough? FYI: I am not very familiar with search engines or search engines APIs

nticaric commented 7 years ago

Yeah it will make your search super fast. This search package works just like a librarian does. You ask him for a book and he looks it up and brings it from a shelf, without searching the whole library.

Exactly this does TNTSearch, it has an inverted index where all words from your documents are stored with their positions. So when you search for the word "cat" it knows right away in which documents this word can be found.

Inverted Index

the94air commented 7 years ago

From the way that you show me,Yaa it is super fast.And if you add jQuery it is exactly like TNT

nticaric commented 7 years ago

Take a look at the demo to see how fast it is :)

the94air commented 7 years ago

it is awesome. can you show me a simple jquey code to do that? Thanks a lot

nticaric commented 7 years ago

It's not jQuery :D Try to play with the source code https://github.com/teamtnt/tntsearch-demo

the94air commented 7 years ago

I should preform action when ever i make query. am I right is that the right way to deal with tntseaech EX

    $insert = $db->prepare("INSERT INTO `articles`(`title`, `article`, `slug`) VALUES (:title,:article,:slug)");

    $insert->execute([
        ':title' => $title,
        ':article' => $article,
        ':slug' => $slug
    ]);

    $article_id = $db->lastInsertId();

    $tnt->selectIndex("articles.index");

    $index = $tnt->getIndex();

    $index->insert([
        'id' => $article_id,
        'title' => $title,
        'article' => $article,
        'slug' => $slug
    ]);
the94air commented 7 years ago

I am having an error when i am insert a very big text. that is causing this error Maximum execution time of 30 seconds exceeded

nticaric commented 7 years ago

Seems like you're doing everything wrong :) try to follow one of the tutorials provided on the readme page

the94air commented 7 years ago

I am follow the readme.md tutorials but the problem not in the code. The code is working just fine. i am asking about the Technique.

nticaric commented 7 years ago

So whats your question?

the94air commented 7 years ago

Inserting and updating is taking a lot of time causeing this error max execute time of 30 second exceeded. Should I insert long text as index in TNT search?

nticaric commented 7 years ago

Try this:

$index->beginTransaction();
$index->insert([
        'id' => $article_id,
        'title' => $title,
        'article' => $article,
        'slug' => $slug
    ]);
$index->endTransaction();
the94air commented 7 years ago

i think you meant to say

$index->indexBeginTransaction();
$index->insert([
    'id' => $article_id,
    'title' => $title,
    'article' => $article,
    'slug' => $slug
]);
$index->indexEndTransaction(); 
nticaric commented 7 years ago

Yes :) Is it faster this way?

the94air commented 7 years ago

Yaa it is super fast. Thanks man 👍

the94air commented 7 years ago

I have add a repository showing how did i use TNTsearch. if you see any thing wrong just tell me :smile: https://github.com/the94air/TNT-search-demo

nticaric commented 7 years ago

Yeah, its a good start :) What I would suggest is to learn a little bit about MVC design architecture to better organize your code. After you grasp it, you could write a tutorial to share your knowledge with others

the94air commented 7 years ago

I always use (Slim like) structure in my projects. That was just for demo structure. i attended to use TNTSearch in web apps. And when i get more time i will consider making a tutorial Thank you for the support (I mean 2 days support for my issue) i really appreciate it . thanks again :smiley: