@@ -164,20 +164,25 @@ export async function search<T extends AnyOrama, ResultDocument = TypedDocument<
164
164
165
165
const tokensLength = tokens . length
166
166
167
- if ( tokensLength ) {
167
+ if ( tokensLength || ( properties && properties . length > 0 ) ) {
168
168
// Now it's time to loop over all the indices and get the documents IDs for every single term
169
169
const indexesLength = propertiesToSearch . length
170
170
for ( let i = 0 ; i < indexesLength ; i ++ ) {
171
171
const prop = propertiesToSearch [ i ]
172
172
173
- const tokensLength = tokens . length
174
- for ( let j = 0 ; j < tokensLength ; j ++ ) {
175
- const term = tokens [ j ]
173
+ if ( tokensLength !== 0 ) {
174
+ for ( let j = 0 ; j < tokensLength ; j ++ ) {
175
+ const term = tokens [ j ]
176
176
177
- // Lookup
178
- const scoreList = await orama . index . search ( context , index , prop , term )
177
+ // Lookup
178
+ const scoreList = await orama . index . search ( context , index , prop , term )
179
179
180
- safeArrayPush ( context . indexMap [ prop ] [ term ] , scoreList ) ;
180
+ safeArrayPush ( context . indexMap [ prop ] [ term ] , scoreList ) ;
181
+ }
182
+ } else {
183
+ context . indexMap [ prop ] [ '' ] = [ ]
184
+ const scoreList = await orama . index . search ( context , index , prop , '' )
185
+ safeArrayPush ( context . indexMap [ prop ] [ '' ] , scoreList ) ;
181
186
}
182
187
183
188
const docIds = context . indexMap [ prop ]
0 commit comments