-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
45 lines (41 loc) · 1.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* Simple example of use the SearchInMemory
*
* @author Rafał Piekarski
*/
require_once 'SearchInMemory.php';
$searcher = new SearchInMemory(array(
'docs' => array(
array(
'id' => 1,
'title'=>"Twenty Thousand Leagues Under the Sea",
'keywords' => array('Twenty', 'Thousand', 'Leagues', 'Under', 'the', 'Sea'),
'author' => 'Jules Verne',
),
array(
'id' => 2,
'title'=>"The Forbidden Sea",
'keywords' => array('The', 'Forbidden', 'Sea'),
'author' => 'Sheila A. Nielson ',
),
array(
'id' => 3,
'title'=>"The Girl with the Dragon Tattoo",
'keywords' => array('The', 'Girl', 'with', 'the', 'Dragon', 'Tattoo'),
'author' => 'Stieg Larsson',
),
),
'fulltext_index' => 'keywords',
'indexes' => array('author'),
)
);
$results = $searcher->find(array(
'query' => array(
'phrase' => "sea",
'author' => 'Jules Verne',
),
)
);
echo "Jules Verne book about the sea is: ", $results['results'][0]['title'],"\n";
// var_dump($results);