()
| 138 | * Exercises behavior shared by all join methods. |
| 139 | */ |
| 140 | @Test |
| 141 | public void testJoinAllMethods() throws Exception { |
| 142 | indexEmployeeDocs(); |
| 143 | ModifiableSolrParams p = params("sort", "id asc"); |
| 144 | |
| 145 | assertJQ( |
| 146 | req(p, "q", buildJoinRequest(DEPT_FIELD, DEPT_ID_FIELD, "title:MTS"), "fl", "id"), |
| 147 | "/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'10'},{'id':'12'},{'id':'13'}]}"); |
| 148 | |
| 149 | // empty from |
| 150 | assertJQ( |
| 151 | req(p, "q", buildJoinRequest("noexist_ss_dv", DEPT_ID_FIELD, "*:*", "fl", "id")), |
| 152 | "/response=={'numFound':0,'start':0,'numFoundExact':true,'docs':[]}"); |
| 153 | |
| 154 | // empty to |
| 155 | assertJQ( |
| 156 | req(p, "q", buildJoinRequest(DEPT_FIELD, "noexist_ss_dv", "*:*"), "fl", "id"), |
| 157 | "/response=={'numFound':0,'start':0,'numFoundExact':true,'docs':[]}"); |
| 158 | |
| 159 | // self join... return everyone in same dept(s) as Dave |
| 160 | assertJQ( |
| 161 | req(p, "q", buildJoinRequest(DEPT_FIELD, DEPT_FIELD, "name:dave"), "fl", "id"), |
| 162 | "/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'1'},{'id':'4'},{'id':'5'}]}"); |
| 163 | |
| 164 | // from single-value to multi-value |
| 165 | assertJQ( |
| 166 | req(p, "q", buildJoinRequest(DEPT_ID_FIELD, DEPT_FIELD, "text:develop"), "fl", "id"), |
| 167 | "/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'1'},{'id':'4'},{'id':'5'}]}"); |
| 168 | |
| 169 | // from multi-value to single-value |
| 170 | assertJQ( |
| 171 | req( |
| 172 | p, |
| 173 | "q", |
| 174 | buildJoinRequest(DEPT_FIELD, DEPT_ID_FIELD, "title:MTS"), |
| 175 | "fl", |
| 176 | "id", |
| 177 | "debugQuery", |
| 178 | "true"), |
| 179 | "/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'10'},{'id':'12'},{'id':'13'}]}"); |
| 180 | |
| 181 | // expected outcome for a sub query matching dave joined against departments |
| 182 | final String davesDepartments = |
| 183 | "/response=={'numFound':2,'start':0,'numFoundExact':true,'docs':[{'id':'10'},{'id':'13'}]}"; |
| 184 | |
| 185 | // straight forward query |
| 186 | assertJQ( |
| 187 | req(p, "q", buildJoinRequest(DEPT_FIELD, DEPT_ID_FIELD, "name:dave"), "fl", "id"), |
| 188 | davesDepartments); |
| 189 | |
| 190 | // variable deref in 'from' query |
| 191 | assertJQ( |
| 192 | req( |
| 193 | p, |
| 194 | "q", |
| 195 | buildJoinRequest(DEPT_FIELD, DEPT_ID_FIELD, "$qq"), |
| 196 | "qq", |
| 197 | "{!dismax}dave", |
nothing calls this directly
no test coverage detected