Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用startAt()和endAt方法使用多个搜索键搜索firestore集合_Java_Android_Google Cloud Firestore - Fatal编程技术网

Java 如何使用startAt()和endAt方法使用多个搜索键搜索firestore集合

Java 如何使用startAt()和endAt方法使用多个搜索键搜索firestore集合,java,android,google-cloud-firestore,Java,Android,Google Cloud Firestore,假设我们在people集合中有一个“people”集合,我们有person对象 公共类人物{ 公共字符串人形; 公共字符串名; 公共字符串lastName; } 我想用下面的startAt和endAt方法同时使用firstName和lastName搜索人员 Query Query=FirebaseFirestore.getInstance() .collection(“人”).orderBy(“名字”), 查询。方向。升序)。 orderBy(“lastName”,Query.Directio

假设我们在people集合中有一个“people”集合,我们有person对象

公共类人物{
公共字符串人形;
公共字符串名;
公共字符串lastName;
}
我想用下面的startAt和endAt方法同时使用firstName和lastName搜索人员

Query Query=FirebaseFirestore.getInstance()
.collection(“人”).orderBy(“名字”),
查询。方向。升序)。
orderBy(“lastName”,Query.Direction.ASCENDING).startAt(key.endAt)(key+“\uf8ff”);
FirestoreRecyclerOptions选项=新建FirestoreRecyclerOptions.Builder()
.setQuery(查询,Person.class)
.build();

但是我只能使用firstName或lastName。我怎么能同时使用两者呢?

我不确定startAt和endAt是否适合您。这些都是用来分页的,看起来不像你在这里要做的。如果您只想按某个常见的第一次和最后一次筛选所有人员,只需使用where子句执行常规查询,以筛选这些姓名,并根据需要对其排序:

Query Query=FirebaseFirestore.getInstance()
.收集(“人”)
.whereEqualTo(“姓氏”,您的姓氏)
.whereEqualTo(“名字”,你的名字)
.orderBy(“姓氏”)
.orderBy(“名字”)

谢谢你的回答,但这个答案不是我想要的,我想要的是当我搜索时,它在这里搜索firstName或lastName,逻辑是AND not或AND not AND not QUOTE to I want%LIKE%(就像我们在SQL中拥有的那样)Firestore没有LIKE查询。