Fix date searches
[phinde.git] / README.rst
1 **********************************
2 phinde - generic web search engine
3 **********************************
4 Self-hosted search engine you can use for your static blog or about
5 any other website you want search functionality for.
6
7 My live instance is at http://search.cweiske.de/ and indexes my
8 website, blog and all linked URLs.
9
10
11 ========
12 Features
13 ========
14 - Crawler and indexer with the ability to run many in parallel
15 - Shows and highlights text that contains search words
16 - Boolean search queries:
17
18   - ``foo bar`` searches for ``foo AND bar``
19   - ``foo OR bar``
20   - ``title:foo`` searches for ``foo`` only in the page title
21 - Facets for tag, domain, language and type
22 - Date search:
23
24   - ``before:2016-08-30`` - modification date before that day
25   - ``after:2016-08-30`` - modified after that day
26   - ``date::2016-08-30`` - exact modification day match
27 - Site search
28
29   - Query: ``foo bar site:example.org/dir/``
30   - or use the ``site`` GET parameter:
31     ``/?q=foo&site=example.org/dir``
32 - OpenSearch support with HTML and Atom result lists
33 - Instant indexing with WebSub (formerly PubSubHubbub)
34
35
36 ============
37 Dependencies
38 ============
39 - PHP 5.5+
40 - Elasticsearch 2.0
41 - Gearman
42 - Console_CommandLine
43 - Net_URL2
44
45
46 =====
47 Setup
48 =====
49 #. Install and run Elasticsearch and Gearman
50 #. Get a local copy of the code::
51
52      $ git clone https://git.cweiske.de/phinde.git phinde
53
54 #. Install dependencies via PEAR::
55
56      $ pear install console_commandline net_url2
57
58 #. Point your webserver's document root to phinde's ``www`` directory
59 #. Copy ``data/config.php.dist`` to ``data/config.php`` and adjust it.
60    Make sure your add your domain to the crawl whitelist.
61 #. Run ``bin/setup.php`` which sets up the Elasticsearch schema
62 #. Put your homepage into the queue::
63
64      $ ./bin/process.php http://example.org/
65
66 #. Start at least one worker to process the crawl+index queue::
67
68      $ ./bin/phinde-worker.php
69
70 #. Check phinde's status page in your browser.
71    The number of open tasks should be > 0, the number of workers also.
72
73
74 Re-index when your site changes
75 ===============================
76 When your site changed, the search engine needs to re-crawl and re-index
77 the pages.
78
79 Simply tell phinde that something changed by running::
80
81     $ ./bin/process.php http://example.org/foo.htm
82
83 phinde supports HTML pages and Atom feeds, so if your blog has a feed
84 it's enough to let phinde reindex that one.
85 It will find all linked pages automatically.
86
87
88 Website integration
89 ===================
90 Adding a simple search form to your website is easy.
91 It needs two things:
92
93 - ``<form>`` tag with an action that points to the phinde instance
94 - Search text field with name of ``q``.
95
96 Example::
97
98   <form method="get" action="http://phinde.example.org">
99     <input type="text" name="q" placeholder="Search text"/>
100     <button type="submit">Search</button>
101   </form>
102
103
104 System service
105 ==============
106 When using systemd, you can let it run multiple worker instances when
107 the system boots up:
108
109 #. Copy files ``data/systemd/phinde*.service`` into ``/etc/systemd/system/``
110 #. Adjust user and group names, and the work directories
111 #. Enable three worker processes::
112
113      $ systemctl daemon-reload
114      $ systemctl enable phinde@1
115      $ systemctl enable phinde@2
116      $ systemctl enable phinde@3
117      $ systemctl enable phinde
118      $ systemctl start phinde
119 #. Now three workers are running. Restarting the ``phinde`` service also
120    restarts the workers.
121
122
123
124 Cron job
125 ========
126 Run ``bin/renew-subscriptions.php`` once a day with cron.
127 It will renew the WebSub subscriptions.
128
129
130 =====
131 Howto
132 =====
133
134 Delete index data from one domain::
135
136     $ curl -iv -XDELETE -H 'Content-Type: application/json' -d '{"query":{"term":{"domain":"example.org"}}}' http://127.0.0.1:9200/phinde/_query
137
138 That's delete-by-query 2.0, see
139 https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/delete-by-query-usage.html
140
141
142 ============
143 About phinde
144 ============
145
146 Source code
147 ===========
148 phinde's source code is available from http://git.cweiske.de/phinde.git
149 or the `mirror on github`__.
150
151 __ https://github.com/cweiske/phinde
152
153
154 License
155 =======
156 phinde is licensed under the `AGPL v3 or later`__.
157
158 __ http://www.gnu.org/licenses/agpl.html
159
160
161 Author
162 ======
163 phinde was written by `Christian Weiske`__.
164
165 __ http://cweiske.de/