|
124 | 124 | (DirectoryReader/open index)) |
125 | 125 |
|
126 | 126 | (defn- hyphen-remover |
127 | | - "Replaces hyphens. This is used to expand a token into its components for use in |
128 | | - the full content string. Should be used alongside the unexpanded token so it |
129 | | - is still searchable." |
130 | | - [kw] |
| 127 | + "Replaces hyphens with spaces. This is used to expand a token into its |
| 128 | + components for use in the full content string. Should be used alongside the |
| 129 | + unexpanded token so it is still searchable." |
| 130 | + [f] |
131 | 131 | (fn [m] |
132 | | - (when-some [v (get m kw)] |
| 132 | + (when-some [v (f m)] |
133 | 133 | (str/replace v #"[-]" " ")))) |
134 | 134 |
|
135 | 135 | (defn- period-remover |
| 136 | + "Replaces periods with spaces. This is used to expand a token into its |
| 137 | + components for use in the full content string. Should be used alongside the |
| 138 | + unexpanded token so it is still searchable." |
| 139 | + [f] |
| 140 | + (fn [m] |
| 141 | + (when-some [v (f m)] |
| 142 | + (str/replace v #"[.]" " ")))) |
| 143 | + |
| 144 | +(defn- sentence-period-remover |
136 | 145 | "Removes periods at the end of sentences since the whitespace tokenizer won't." |
137 | | - [kw] |
| 146 | + [f] |
138 | 147 | (fn [m] |
139 | | - (when-some [v (get m kw)] |
| 148 | + (when-some [v (f m)] |
140 | 149 | (str/replace v #"\.(\s|$)" " ")))) |
141 | 150 |
|
142 | | -(def ^:private content-fields |
| 151 | +(def ^:private content-items |
143 | 152 | [:artifact-id |
144 | 153 | (hyphen-remover :artifact-id) |
145 | 154 | :group-id |
146 | 155 | (hyphen-remover :group-id) |
147 | | - (period-remover :description) |
| 156 | + ;; Include 'group name' & 'group name/artifact-name' in content (for a |
| 157 | + ;; group-id of group.name) to aid in searching for things where new projects |
| 158 | + ;; had to be deployed under a domain-based group |
| 159 | + (period-remover :group-id) |
| 160 | + (period-remover #(->> % ((juxt :group-id :artifact-id)) (str/join "/"))) |
| 161 | + ;; Include 'group-name/artifact-name' in content to allow |
| 162 | + ;; the "group-name/artifact-name" phrase to find it |
| 163 | + #(->> % ((juxt :group-id :artifact-id)) (str/join "/")) |
| 164 | + (sentence-period-remover :description) |
148 | 165 | :url |
149 | 166 | :version |
150 | 167 | #(->> % :authors (str/join " "))]) |
|
191 | 208 | (.add (string-field "version" version))) |
192 | 209 | ;; content field containing all values to use as the default search field |
193 | 210 | (.add (text-field content-field-name |
194 | | - (str/join " " ((apply juxt content-fields) jar)))) |
| 211 | + (str/join " " ((apply juxt content-items) jar)))) |
195 | 212 | ;; adds a boost field based on the ratio of downloads of the jar to the |
196 | 213 | ;; total number of downloads. This is then applied to the query below. |
197 | 214 | (.add (DoubleDocValuesField. boost-field-name download-boost)))) |
|
0 commit comments