PageRenderTime 255ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/ucengine/src/backends/search/solr/uce_solr_commiter.erl

Relevant Search: With Applications for Solr and Elasticsearch

For more in depth reading about search, ranking and generally everything you could ever want to know about how lucene, elasticsearch or solr work under the hood I highly suggest this book. Easily one of the most interesting technical books I have read in a long time. If you are tasked with solving search relevance problems even if not in Solr or Elasticsearch it should be your first reference. Amazon Affiliate Link
http://github.com/AF83/ucengine
Erlang | 60 lines | 31 code | 12 blank | 17 comment | 0 complexity | 967b6f2192b2925ef6d810314cf3bf0c MD5 | raw file
 1%%
 2%%  U.C.Engine - Unified Collaboration Engine
 3%%  Copyright (C) 2011 af83
 4%%
 5%%  This program is free software: you can redistribute it and/or modify
 6%%  it under the terms of the GNU Affero General Public License as published by
 7%%  the Free Software Foundation, either version 3 of the License, or
 8%%  (at your option) any later version.
 9%%
10%%  This program is distributed in the hope that it will be useful,
11%%  but WITHOUT ANY WARRANTY; without even the implied warranty of
12%%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13%%  GNU Affero General Public License for more details.
14%%
15%%  You should have received a copy of the GNU Affero General Public License
16%%  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17%%
18-module(uce_solr_commiter).
19
20-behaviour(gen_server).
21
22-include("uce.hrl").
23
24-export([start_link/0]).
25
26-export([init/1,
27         code_change/3,
28         handle_call/3,
29         handle_cast/2,
30         handle_info/2,
31         terminate/2]).
32
33start_link() ->
34    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
35
36init([]) ->
37    gen_server:cast(?MODULE, run),
38    {ok, nothing}.
39
40handle_call(_ , _, State) ->
41    {reply, ok, State}.
42
43handle_cast(run, State) ->
44    [CommitInterval] = utils:get(config:get(solr), [commit_interval], [1000]),
45    timer:sleep(CommitInterval),
46    {ok, commited} = uce_event_solr_search:commit(),
47    handle_cast(run, State),
48    {noreply, State};
49
50handle_cast(_, State) ->
51    {noreply, State}.
52
53code_change(_,State,_) ->
54    {ok, State}.
55
56handle_info(_Info, State) ->
57    {reply, State}.
58
59terminate(_Reason, _State) ->
60    ok.