this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

search: ensure most keyword term matches are case-insensitive

+30 -12
+20 -12
search/query.go
··· 107 107 108 108 if p.Author != nil { 109 109 filters = append(filters, map[string]interface{}{ 110 - "term": map[string]interface{}{"did": p.Author.String()}, 110 + "term": map[string]interface{}{"did": map[string]interface{}{ 111 + "value": p.Author.String(), 112 + "case_insensitive": true, 113 + }}, 111 114 }) 112 115 } 113 116 114 117 if p.Mentions != nil { 115 118 filters = append(filters, map[string]interface{}{ 116 - "term": map[string]interface{}{"mention_did": p.Mentions.String()}, 119 + "term": map[string]interface{}{"mention_did": map[string]interface{}{ 120 + "value": p.Mentions.String(), 121 + "case_insensitive": true, 122 + }}, 117 123 }) 118 124 } 119 125 120 126 if p.Lang != nil { 121 127 // TODO: extracting just the 2-char code would be good 122 128 filters = append(filters, map[string]interface{}{ 123 - "term": map[string]interface{}{"lang_code_iso2": p.Lang.String()}, 129 + "term": map[string]interface{}{"lang_code_iso2": map[string]interface{}{ 130 + "value": p.Lang.String(), 131 + "case_insensitive": true, 132 + }}, 124 133 }) 125 134 } 126 135 ··· 144 153 }) 145 154 } 146 155 147 - if p.Lang != nil { 148 - // TODO: extracting just the 2-char code would be good 149 - filters = append(filters, map[string]interface{}{ 150 - "term": map[string]interface{}{"lang_code_iso2": p.Lang.String()}, 151 - }) 152 - } 153 - 154 156 if p.URL != "" { 155 157 filters = append(filters, map[string]interface{}{ 156 - "term": map[string]interface{}{"url": NormalizeLossyURL(p.URL)}, 158 + "term": map[string]interface{}{"url": map[string]interface{}{ 159 + "value": NormalizeLossyURL(p.URL), 160 + "case_insensitive": true, 161 + }}, 157 162 }) 158 163 } 159 164 160 165 if p.Domain != "" { 161 166 filters = append(filters, map[string]interface{}{ 162 - "term": map[string]interface{}{"domain": p.Domain}, 167 + "term": map[string]interface{}{"domain": map[string]interface{}{ 168 + "value": p.Domain, 169 + "case_insensitive": true, 170 + }}, 163 171 }) 164 172 } 165 173
+10
search/query_test.go
··· 339 339 t.Fatal(err) 340 340 } 341 341 assert.Equal(1, len(res.Hits.Hits)) 342 + res, err = DoSearchPosts(ctx, &dir, escli, testPostIndex, "post #Trick", 0, 20) 343 + if err != nil { 344 + t.Fatal(err) 345 + } 346 + assert.Equal(1, len(res.Hits.Hits)) 347 + res, err = DoSearchPosts(ctx, &dir, escli, testPostIndex, "post #trick #allMustMatch", 0, 20) 348 + if err != nil { 349 + t.Fatal(err) 350 + } 351 + assert.Equal(0, len(res.Hits.Hits)) 342 352 343 353 // mention query 344 354 res, err = DoSearchPosts(ctx, &dir, escli, testPostIndex, "@other.example.com", 0, 20)