Package org.sindice.siren.qparser.json.dsl

Examples of org.sindice.siren.qparser.json.dsl.QueryBuilder


    assertParser(bool);
  }

  @Test
  public void testBooleanWithMultipleClauses() throws QueryNodeException {
    final QueryBuilder build = new QueryBuilder();
    final BooleanQuery bool = build.newBoolean()
                                   .with(build.newNode("aaa"))
                                   .without(build.newNode("bbb"))
                                   .optional(build.newTwig("ccc").with(build.newNode("ddd")));
    assertParser(bool);
  }
View Full Code Here


   * Get a list of queries that are based on the JSON query syntax
   *
   * @see JsonQueryParser
   */
  private String[] getJsonQueries() throws QueryNodeException {
    final QueryBuilder b = new QueryBuilder();
    final String[] queries = {
      b.newNode("Cambridge").toString(),
      b.newTwig("placeOfPublication").with(b.newNode("Cambridge")).toString(),
      b.newTwig("publisher").with(b.newNode("Cambridge Scholars")).toString(),
      b.newTwig("subject").with(b.newNode("Environmental")).toString(),
      b.newBoolean().with(b.newTwig("subject").with(b.newNode("Environmental")))
                    .with(b.newTwig("issued").with(b.newNode("2009"))).toString(),
      b.newTwig("type").with(b.newNode("text"))
                       .with(b.newNode("monographic")).toString(),
      b.newTwig("identifier").with(
        // here, twig with empty root node to represent first nested entity node
        b.newTwig().with(b.newTwig("id").with(b.newNode("9780852935392")))
                   .with(b.newTwig("type").with(b.newNode("isbn")))
      ).toString(),
      b.newBoolean().with(b.newTwig("subject").with(b.newNode("Computer security")))
                    .with(b.newTwig("isPartOf").with(
                      // here, twig with empty root node to represent first nested entity node
                      b.newTwig().with(
                        b.newTwig("identifier").with(
                          // here, twig with empty root node to represent second nested entity node
                          b.newTwig().with(
                            b.newTwig("id").with(b.newNode("\"0302-9743\""))
                          )
                        )
                      )
                    )).toString()
    };
View Full Code Here

    final NodeTermQuery owner = new NodeTermQuery(new Term("", "DeviceOwner"));
    owner.setDatatype("json:field");

    // Use the query builder to create twig query using the JSON query syntax.
    final QueryBuilder builder = new QueryBuilder();
    final TwigQuery twq = builder.newTwig(owner.toString("json"))
                           .with(
                             builder.newTwig(website.toString("json"))
                                    .with(builder.newNode(uri.toString("json"))),
                             2);

    query.setQuery(twq.toString());
    return query;
  }
View Full Code Here

   * Get a list of queries that are based on the JSON query syntax
   *
   * @see JsonQueryParser
   */
  private String[] getJsonQueries() throws QueryNodeException {
    final QueryBuilder b = new QueryBuilder();
    final String[] queries = {
      b.newNode("\"Marie Antoinette\"").toString(),
      b.newTwig("genre").with(b.newNode("Drama")).toString(),
      b.newBoolean().with(b.newTwig("genre").with(b.newNode("Drama")))
                    .with(b.newTwig("year").with(b.newNode("2010"))).toString(),
      b.newTwig("director").with(
        // here, twig with empty root node to represent first nested entity node
        b.newTwig().with(b.newTwig("last_name").with(b.newNode("Eastwood")))
                   .with(b.newTwig("first_name").with(b.newNode("Clint")))
      ).toString(),
      b.newTwig("actors").with(
        // here, twig with empty root node to represent first nested entity node
        b.newTwig().with(
          // here, twig with empty root to represent the wildcard on the field name
          b.newTwig().with(b.newNode("Timberlake"))
        )
      )
                         .with(
        // here, twig with empty root node to represent first nested entity node
        b.newTwig().with(
          // here, twig with empty root to represent the wildcard on the field name
          b.newTwig().with(b.newNode("Eisenberg"))
        )
      ).toString()
    };
    return queries;
  }
View Full Code Here

  public void testSimpleJsonQuery()
  throws IOException, SolrServerException, QueryNodeException {
    this.addJsonString("1", "{ \"aaa\" :  { \"bbb\" : \"ccc\" } }");

    SolrQuery query = new SolrQuery();
    final QueryBuilder b = new QueryBuilder();
    query.setQuery(b.newTwig("aaa").with(b.newNode("ccc"), 3).toString());
    query.setRequestHandler("json");
    String[] results = this.search(query, ID_FIELD);
    assertEquals(1, results.length);

    query = new SolrQuery();
    query.setQuery(b.newTwig("aaa").with(b.newNode("ccc"), 2).toString());
    query.setRequestHandler("json");
    results = this.search(query, ID_FIELD);
    assertEquals(0, results.length);
  }
View Full Code Here

        "\"_value_\" : \"http://xmlns.com/foaf/0.1/Person\", " +
        "\"_datatype_\" : \"uri\" " +
        "} }");

    final SolrQuery query = new SolrQuery();
    final QueryBuilder b = new QueryBuilder();
    query.setQuery(b.newTwig("uri").with(b.newNode("'foaf:Person'")).toString());
    query.setRequestHandler("json");
    final String[] results = this.search(query, ID_FIELD);
    assertEquals(1, results.length);
  }
View Full Code Here

        "\"_value_\" : \"http://xmlns.com/foaf/0.1/Person\", " +
        "\"_datatype_\" : \"uri\" " +
        "} }");

    final SolrQuery query = new SolrQuery();
    final QueryBuilder b = new QueryBuilder();
    query.setQuery(b.newTwig("uri").with(b.newNode("uri('http://xmlns.com/foaf/0.1/Person')")).toString());
    query.setRequestHandler("json");
    final String[] results = this.search(query, ID_FIELD);
    assertEquals(1, results.length);
  }
View Full Code Here

TOP

Related Classes of org.sindice.siren.qparser.json.dsl.QueryBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.