在SearchView中应用词干以从Firebase数据库中获取数据 [英] Applying Word Stemming in SearchView for fetch data from Firebase database
问题描述
我需要使用SeachView
或搜索对话框从Firebase数据库中获取用户列表,我认为词干搜索最适合我的应用.
I need to fetch list of users from Firebase database using SeachView
or search dialog and I think word stemming will be best for my app.
不要求输入代码,但请告诉我它的方法.
Not asking for code but please tell me the alorigthm for it.
推荐答案
要实现所需的功能,您需要执行如下查询:
To achieve what you want, you need to execute a query which should look like this:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference usersRef = rootRef.child("users");
Query query = usersRef.orderByChild("name").equalTo(newText);
因此,每次创建搜索时,您都应该返回一个新查询.因此,据此,每次您要在新条件下进行过滤时,都需要:
So everytime you create a search you should return a new query. So according to this, every time you want to filter on a new condition, you will need to:
-
基于新过滤器创建一个新查询:
Query query = usersRef.orderByChild("name").equalTo(newText);
为此新创建的查询添加侦听器.
Attach a listener to this new created query.
使用此新创建的查询的结果创建一个新的适配器,或使用notifydatasetchanged()
方法更新现有的适配器.
Create a new adapter with the results of this new created query, or update the existing one using notifydatasetchanged()
method.
这篇关于在SearchView中应用词干以从Firebase数据库中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!