Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

Searching in Firebase without server side code

I am trying to get all the users having the name that contains a given string from Firebase. For example, if I have these users:

Devid, Andy, Bob

I would like to get all the users having the name that contains a 'D' so I expect this as result:

Devid, Andy

This is my Firebase's structure at the moment:

enter image description here

Since Firebase is case sensitive I've created an attribute name_ that contains the lowercase name.

Using startAt and endAt I can get all the users with the name starting with a defined string

ref.orderByChild("name_").startAt(text).endAt(text+"uf8ff").on('value', ...);

But this gives me only the users having the name that starts with a given string, for example if text is 'D' I'll get:

Devid

1) At the moment my query means, "give me all the users having name_ that starts with a given string" is there a way to make it mean "give me all the users which name contains a given string"? EDIT: NO

Firebase Queries don't have anything similar to full-text search operators. To accomplish those, you'll either have to integrate an external full-text search engine, or come up with a very elaborate custom indexing scheme. Firebase and indexing/search

2) At the moment I don't want to have server side code, what can be a good and efficient way to implement custom indexes?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...