Tutorial #009: Using queries to retrieve documents using Bloomreach XM and XIN Mods

In this Bloomreach XM with XIN Mods tutorial we're going to talk about executing simple queries using the XIN Mods Query API.

All operators

Code from the video

 

									it("should list recipes with a certain ingredient", async () => {
									
									    const conn = xinmods.connectTo("http://localhost:8080", "admin", "admin");
									
									    const queryStr = (
									        conn.newQuery()
									            .type("xinmods:recipe")
									            .includePath("/content/documents/recipes")
									            .where()
									                .or()
									                    .contains("xinmods:ingredient/xinmods:string", "garlic")
									                    .contains("xinmods:ingredient/xinmods:string", "onion")
									                .end()
									            .end()
									            .orderBy("xinmods:title")
									        .build()
									    );
									
									    console.log("Query Str: ", queryStr);
									
									    const queryResponse = await conn.executeQuery(queryStr);
									
									    for (const resultDoc of queryResponse.documents) {
									        console.log("result: ", resultDoc.items.title);
									    }
									
									});
									

Also Read