Searching in Firebase without server side code

前端 未结 2 947
独厮守ぢ
独厮守ぢ 2020-11-30 08:17

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
2条回答
  •  日久生厌
    2020-11-30 08:56

    oxyzen library in github does that given you do inserts and updates with some wrapped firebase

    for the indexing part basically the function:

    1. JSON stringifies a document.
    2. removes all the property names and JSON to eave only the data (regex).
    3. removes all xml tags (therefore also html) and attributes (remember old guidance, "data should not be in xml attributes") to leave only the pure text if xml or html was present.
    4. removes all special chars and substitute with space (regex)
    5. substitutes all instances of multiple spaces with one space (regex)
    6. splits to spaces and cycles:
    7. for each word adds refs to the document in some index structure in your db tha basically contains childs named with words with childs named with an escaped version of "ref/inthedatabase/dockey"
    8. then inserts the document as a normal firebase application would do

    in the oxyzen implementation, subsequent updates of the document ACTUALLY reads the index and updates it, removing the words that don't match anymore, and adding the new ones.

    subsequent searches of words can easily find documents in the words child. multiple words searches are implemented using hits

提交回复
热议问题