在 SearchView 中应用 Word Stemming 从 Firebase 数据库中获取数据 [英] Applying Word Stemming in SearchView for fetch data from Firebase database

查看:13
本文介绍了在 SearchView 中应用 Word Stemming 从 Firebase 数据库中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 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:

  1. 基于新过滤器创建一个查询:

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 中应用 Word Stemming 从 Firebase 数据库中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆