-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
References #27
- Loading branch information
Michael Klishin
committed
May 15, 2013
1 parent
30ca681
commit 77a7562
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
test/clojurewerkz/elastisch/native_api/queries/custom_score_query_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(ns clojurewerkz.elastisch.native-api.queries.custom-score-query-test | ||
(:require [clojurewerkz.elastisch.native.document :as doc] | ||
[clojurewerkz.elastisch.native.index :as idx] | ||
[clojurewerkz.elastisch.query :as q] | ||
[clojurewerkz.elastisch.fixtures :as fx] | ||
[clojurewerkz.elastisch.test.helpers :as th]) | ||
(:use clojure.test clojurewerkz.elastisch.native.response)) | ||
|
||
(th/maybe-connect-native-client) | ||
(use-fixtures :each fx/reset-indexes fx/prepopulate-people-index) | ||
|
||
;; | ||
;; Tests | ||
;; | ||
|
||
(deftest ^{:query true} test-custom-score-query-with-a-basic-script | ||
(let [response (doc/search "people" "person" :query (q/custom-score :query (q/match-all) | ||
:script "doc['age'].value")) | ||
hits (hits-from response) | ||
scores (vec (map :_score hits))] | ||
(is (= [37.0 29.0 28.0 22.0] scores)))) |
19 changes: 19 additions & 0 deletions
19
test/clojurewerkz/elastisch/rest_api/queries/custom_score_query_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(ns clojurewerkz.elastisch.rest-api.queries.custom-score-query-test | ||
(:require [clojurewerkz.elastisch.rest.document :as doc] | ||
[clojurewerkz.elastisch.rest.index :as idx] | ||
[clojurewerkz.elastisch.query :as q] | ||
[clojurewerkz.elastisch.fixtures :as fx]) | ||
(:use clojure.test clojurewerkz.elastisch.rest.response)) | ||
|
||
(use-fixtures :each fx/reset-indexes fx/prepopulate-people-index) | ||
|
||
;; | ||
;; Tests | ||
;; | ||
|
||
(deftest ^{:query true} test-custom-score-query-with-a-basic-script | ||
(let [response (doc/search "people" "person" :query (q/custom-score :query (q/match-all) | ||
:script "doc['age'].value")) | ||
hits (hits-from response) | ||
scores (vec (map :_score hits))] | ||
(is (= [37.0 29.0 28.0 22.0] scores)))) |