this repo has no description
0
fork

Configure Feed

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

palomar: tweak non-typeahead profile search

+55 -4
+55 -4
search/query.go
··· 93 93 if err := checkParams(offset, size); err != nil { 94 94 return nil, err 95 95 } 96 + 96 97 queryStr, filters := ParseQuery(ctx, dir, q) 97 98 basic := map[string]interface{}{ 98 99 "simple_query_string": map[string]interface{}{ 99 - "query": queryStr, 100 - "fields": []string{"everything"}, 100 + "query": queryStr, 101 + "fields": []string{ 102 + "handle^3", 103 + "display_name^2", 104 + "everything", 105 + }, 101 106 "flags": "AND|NOT|OR|PHRASE|PRECEDENCE|WHITESPACE", 102 107 "default_operator": "and", 103 108 "lenient": true, 104 109 "analyze_wildcard": false, 105 110 }, 106 111 } 112 + 107 113 query := map[string]interface{}{ 108 114 "query": map[string]interface{}{ 109 115 "bool": map[string]interface{}{ ··· 112 118 map[string]interface{}{"term": map[string]interface{}{"has_avatar": true}}, 113 119 map[string]interface{}{"term": map[string]interface{}{"has_banner": true}}, 114 120 }, 115 - "filter": filters, 116 - "boost": 1.0, 121 + "minimum_should_match": 0, 122 + "filter": filters, 123 + "boost": 0.5, 117 124 }, 118 125 }, 119 126 "size": size, 120 127 "from": offset, 128 + } 129 + 130 + // special-case: exact string match of handle 131 + if strings.HasPrefix(q, "@") && !strings.Contains(q, " ") { 132 + q = q[1:] 133 + query["query"] = map[string]interface{}{ 134 + "prefix": map[string]interface{}{ 135 + "handle": map[string]interface{}{ 136 + "value": q, 137 + }, 138 + }, 139 + } 140 + } 141 + 142 + // boost exact handle prefix match, if q is single simple term 143 + if len(q) >= 3 && !strings.ContainsAny(q, " .") { 144 + query["rescore"] = map[string]interface{}{ 145 + "window_size": 100, 146 + "query": map[string]interface{}{ 147 + "rescore_query": map[string]interface{}{ 148 + "boosting": map[string]interface{}{ 149 + "positive": map[string]interface{}{ 150 + "prefix": map[string]interface{}{ 151 + "handle": map[string]interface{}{ 152 + "value": q + ".", 153 + }, 154 + }, 155 + }, 156 + // downrank *.bsky.social (vs custom domain) 157 + // wildcard is expensive, so only in rescore 158 + "negative": map[string]interface{}{ 159 + "wildcard": map[string]interface{}{ 160 + "handle": map[string]interface{}{ 161 + "value": "*.bsky.social", 162 + }, 163 + }, 164 + }, 165 + "negative_boost": 0.5, 166 + }, 167 + }, 168 + "query_weight": 0.5, 169 + "rescore_query_weight": 2.0, 170 + }, 171 + } 121 172 } 122 173 123 174 return doSearch(ctx, escli, index, query)