|
49 | 49 | (println "bulking") |
50 | 50 | (core/extract! {})) |
51 | 51 |
|
| 52 | + (defn >> [a] (prn a) a) |
| 53 | + |
52 | 54 | ; fulltext search with generated database |
53 | 55 | (let [conn (d/get-conn "target/docs-db" |
54 | 56 | datalevin/db-schemas) |
55 | 57 |
|
56 | 58 | db (d/db conn) |
57 | 59 |
|
58 | | - result (doall (d/q '[:find ?e ?a ?v ;(pull ?e [*]) |
59 | | - :in $ ?q |
60 | | - :where |
61 | | - [(fulltext $ ?q {:top 30 |
62 | | - :domains ["definition-name"]}) |
63 | | - [[?e ?a ?v]]]] |
64 | | - db |
65 | | - "a"))] |
| 60 | + datoms (->> (d/fulltext-datoms db |
| 61 | + "ass" |
| 62 | + {:top 30 |
| 63 | + :domains ["definition-name" |
| 64 | + "namespace-name" |
| 65 | + "project-name"]}) |
| 66 | + (map first) |
| 67 | + (d/pull-many db '[:definition/id |
| 68 | + :definition/name |
| 69 | + :definition/doc |
| 70 | + :namespace/id |
| 71 | + :namespace/name |
| 72 | + :namespace/doc |
| 73 | + :project/id |
| 74 | + :project/artifact |
| 75 | + :project/group]))] |
66 | 76 | (d/close conn) |
67 | | - result) |
| 77 | + datoms) |
68 | 78 |
|
69 | | - ; fulltext raw search with generated database |
| 79 | +; fulltext raw search with generated database |
70 | 80 | (let [lmdb (d/open-kv "target/docs-db") |
71 | 81 | engine (d/new-search-engine lmdb {:query-analyzer (su/create-analyzer |
72 | 82 | {:tokenizer (su/create-regexp-tokenizer #"[\s:/\.;,!=?\"'()\[\]{}|<>&@#^*\\~`\-]+") |
|
121 | 131 | ; tests with fulltext search |
122 | 132 | (let [conn (d/get-conn "target/docs-db" datalevin/db-schemas) |
123 | 133 | db (d/db conn) |
124 | | - result (doall (d/q '[:find ?e ?name ?a ?v |
| 134 | + result (doall (d/q '[:find ?e ?name ?a ?v ?b ?d |
125 | 135 | :in $ ?q |
126 | 136 | :where |
127 | | - [(fulltext $ ?q) [[?e ?a ?v]]] |
| 137 | + [(fulltext $ ?q) [[?e ?a ?v ?b ?d]]] |
128 | 138 | [?e :definition/name ?name]] |
129 | 139 | db |
130 | 140 | "assoc"))] |
|
135 | 145 | (let [query-analyzer (su/create-analyzer |
136 | 146 | {:tokenizer (su/create-regexp-tokenizer #"[\s:/\.;,!=?\"'()\[\]{}|<>&@#^*\\~`\-]+") |
137 | 147 | :token-filters [su/lower-case-token-filter]}) |
| 148 | + |
138 | 149 | analyzer (su/create-analyzer |
139 | 150 | {:tokenizer (su/create-regexp-tokenizer #"[\s:/\.;,!=?\"'()\[\]{}|<>&@#^*\\~`\-]+") |
140 | 151 | :token-filters [su/lower-case-token-filter |
|
148 | 159 | {:search-domains {"txt" {:analyzer analyzer |
149 | 160 | :query-analyzer query-analyzer}}}) |
150 | 161 |
|
151 | | - data [{:text "abs"} |
| 162 | + data [{:text "a"} |
| 163 | + {:text "abs"} |
152 | 164 | {:text "assoc!"} |
153 | 165 | {:text "assoc"} |
154 | 166 | {:text "assoc-in"} |
155 | 167 | {:text "assoc-dom"} |
156 | 168 | {:text "assoc-meta"} |
157 | | - {:text "associative?"}] |
| 169 | + {:text "associative?"} |
| 170 | + {:text "b"} |
| 171 | + {:text "ba"} |
| 172 | + {:text "bas"}] |
158 | 173 |
|
159 | 174 | _transact (d/transact! conn data) |
160 | 175 |
|
161 | | - result (d/q '[:find ?e ?a ?v |
162 | | - :in $ ?q |
163 | | - :where [(fulltext $ ?q {:domains ["txt"] |
164 | | - :display :refs}) [[?e ?a ?v]]]] |
165 | | - (d/db conn) |
166 | | - "a")] |
| 176 | + result (->> (d/q '[:find ?i |
| 177 | + :in $ ?q |
| 178 | + :where |
| 179 | + [(fulltext $ ?q {:top 20}) [[?e]]] |
| 180 | + [?e :text ?i]] |
| 181 | + (d/db conn) |
| 182 | + "assoc-me") |
| 183 | + doall)] |
167 | 184 |
|
168 | 185 | (d/close conn) |
169 | 186 | (util/delete-files dir) |
170 | 187 |
|
171 | 188 | result) |
172 | 189 |
|
173 | | - ; tests with fulltext and analyzer on a raw query |
| 190 | +; tests with fulltext and analyzer on a raw query |
174 | 191 | (let [query-analyzer (su/create-analyzer |
175 | 192 | {:tokenizer (su/create-regexp-tokenizer #"[\s:/\.;,!=?\"'()\[\]{}|<>&@#^*\\~`\-]+") |
176 | 193 | :token-filters [su/lower-case-token-filter]}) |
|
186 | 203 | :analyzer analyzer |
187 | 204 | :include-text? true |
188 | 205 | :domain "definition-name"}) |
189 | | - input {1 "abs" |
| 206 | + input {0 "a" |
| 207 | + 1 "abs" |
190 | 208 | 2 "assoc!" |
191 | 209 | 3 "assoc" |
192 | 210 | 4 "assoc-in" |
193 | 211 | 5 "assoc-dom" |
194 | 212 | 6 "assoc-meta" |
195 | | - 7 "associative?"} |
| 213 | + 7 "associative?" |
| 214 | + 8 "b" |
| 215 | + 9 "ba" |
| 216 | + 10 "bas"} |
196 | 217 |
|
197 | 218 | _transact (doseq [[k v] input] |
198 | 219 | (d/add-doc engine k v)) |
199 | 220 |
|
200 | | - result (doall (d/search engine "a" {:top 20 :display :texts}))] |
| 221 | + result (doall (d/search engine "assoc-m" {:top 20 :display :texts}))] |
201 | 222 |
|
202 | 223 | (d/close-kv lmdb) |
203 | 224 |
|
204 | 225 | result)) |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
|
0 commit comments