QueryBuilder.select line in couchbaselite Android published example not returning expected result

Blake,

I included the code fragment; as there are several examples on the published site for Couchbase Android Lite EE Java. I included the example that I am using for reference.

The published basic example works with the exception of the QueryBuilder.select line.

The example is returning a null result set.

I would have expected it to return a result set of 1 item. I stepped it thru the Android studio debugger on a actual android device.

Kind Regards,

Michael Fene’

// One-off initialization
CouchbaseLite.init(context);
Log.i(TAG,“Initialized CBL”);

    //
    // <.>
    // Create a database
    Log.i(TAG, "Starting DB");
    DatabaseConfiguration cfg = new DatabaseConfiguration();
    Database database = null;
    try {
        database = new Database(  "mydb", cfg);
    } catch (CouchbaseLiteException e) {
        e.printStackTrace();
    }

    // <.>
    // Create a new document (i.e. a record) in the database.
    MutableDocument mutableDoc =
            new MutableDocument().setFloat("version", 2.0f)
                    .setString("type", "SDK");

    // <.>
    // Save it to the database.
    try {
        database.save(mutableDoc);
    } catch (CouchbaseLiteException e) {
        e.printStackTrace();
    }

    // <.>
    // Retrieve and update a document.
    mutableDoc =
            database.getDocument(mutableDoc.getId())
                    .toMutable()
                    .setString("language", "Java");
    try {
        database.save(mutableDoc);
    } catch (CouchbaseLiteException e) {
        e.printStackTrace();
    }

    // <.>
    // Retrieve immutable document and log the document ID
    // generated by the database and some document properties
    Document document;
    document = database.getDocument(mutableDoc.getId());
    Log.i(TAG, String.format("Document ID :: %s", document.getId()));
    Log.i(TAG, String.format("Learning :: %s:", document.getString("language")));

    // <.>
    // Create a query to fetch documents of type SDK.
    try {
        ResultSet rs =
                QueryBuilder.select(SelectResult.all())
                        .from(DataSource.database(database))
                        .where(Expression.property("type").equalTo(Expression.string("SDK")))
                        .execute();
        Log.i(TAG,
                String.format("Number of rows :: %n",
                        rs.allResults().size()));
    } catch (CouchbaseLiteException e) {
        e.printStackTrace();
    }

At each step you can use document.toJSON(), to print the contents of the document to make sure the saved value is actually saved