PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/ucengine/src/tests/solr_tests.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 | 47 lines | 25 code | 5 blank | 17 comment | 0 complexity | acdb2a4157f162f3a32b7937c94aa5e1 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(solr_tests).
19
20-include("uce.hrl").
21-include_lib("eunit/include/eunit.hrl").
22
23-export([test_add/1, test_search/1]).
24
25solr_test_() ->
26    { setup
27    , fun fixtures:setup/0
28    , fun fixtures:teardown/1
29    , fun([Domain, _, _]) ->
30        [ ?_test(test_add(Domain))
31        , ?_test(test_search(Domain))
32        ]
33      end
34    }.
35
36test_add(Domain) ->
37    {ok, created} = uce_event_solr_search:add(Domain, #uce_event{id=utils:random(),
38                                                                 datetime=utils:now(),
39                                                                 location="testmeeting",
40                                                                 from="chuck_norris",
41                                                                 type="test_solr_event",
42                                                                 metadata=[{"text","This is a test event."}]}).
43
44test_search(Domain) ->
45    timer:sleep(2000),
46    ?assertMatch({ok, _NumTotal, [_]},
47                 uce_event_solr_search:list(Domain, "", ["This"], "", [], 0, infinity, "", 0, 1, asc)).