incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [39/39] git commit: Adding some sample code with the simple RPC.
Date Thu, 28 Feb 2013 03:07:36 GMT
Updated Branches:
  refs/heads/0.2-dev-clientrpc [created] c2d50fa92


Adding some sample code with the simple RPC.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/c2d50fa9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/c2d50fa9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/c2d50fa9

Branch: refs/heads/0.2-dev-clientrpc
Commit: c2d50fa9205861371b2c0da75cc2dd315420dc2f
Parents: 11f5141
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Feb 27 22:06:07 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Feb 27 22:06:07 2013 -0500

----------------------------------------------------------------------
 .../blur/testsuite/SampleSimpleDocument.java       |   63 +++++++++++
 .../blur/testsuite/SampleSimpleDocumentGroup.java  |   82 +++++++++++++++
 2 files changed, 145 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c2d50fa9/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocument.java
----------------------------------------------------------------------
diff --git a/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocument.java
b/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocument.java
new file mode 100644
index 0000000..42b1b5b
--- /dev/null
+++ b/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocument.java
@@ -0,0 +1,63 @@
+package org.apache.blur.testsuite;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.List;
+
+import org.apache.blur.thrift.StringField;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.Document;
+import org.apache.blur.thrift.generated.DocumentRecord;
+import org.apache.blur.thrift.generated.DocumentResult;
+import org.apache.blur.thrift.generated.DocumentService;
+import org.apache.blur.thrift.generated.DocumentService.Iface;
+import org.apache.thrift.TException;
+
+public class SampleSimpleDocument {
+
+  public static void main(String[] args) throws BlurException, TException {
+
+    DocumentService.Iface client = getClient();
+
+    DocumentRecord record = new DocumentRecord();
+    record.setId("id1");
+    Document document = new Document();
+    document.addToFields(new StringField("test", "test"));
+    record.setDocument(document);
+
+    client.updateRecord("t1", record);
+
+    DocumentResult result = client.searchRecords("t1", "test:test");
+    System.out.println("Total Hits:" + result.getTotalHits());
+    List<DocumentRecord> documents = result.getDocuments();
+    List<Double> scores = result.getScores();
+    for (int i = 0; i < documents.size(); i++) {
+      DocumentRecord documentRecord = documents.get(i);
+      Double score = scores.get(i);
+      System.out.println("Score :" + score);
+      System.out.println("Doc   :" + documentRecord);
+    }
+
+    client.deleteRecord("t1", "id1");
+
+  }
+
+  private static Iface getClient() {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c2d50fa9/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocumentGroup.java
----------------------------------------------------------------------
diff --git a/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocumentGroup.java
b/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocumentGroup.java
new file mode 100644
index 0000000..cf2cf66
--- /dev/null
+++ b/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SampleSimpleDocumentGroup.java
@@ -0,0 +1,82 @@
+package org.apache.blur.testsuite;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.List;
+
+import org.apache.blur.thrift.StringField;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.Document;
+import org.apache.blur.thrift.generated.DocumentGroup;
+import org.apache.blur.thrift.generated.DocumentGroupResult;
+import org.apache.blur.thrift.generated.DocumentGroupService;
+import org.apache.blur.thrift.generated.DocumentGroupService.Iface;
+import org.apache.blur.thrift.generated.DocumentRecord;
+import org.apache.thrift.TException;
+
+public class SampleSimpleDocumentGroup {
+
+  public static void main(String[] args) throws BlurException, TException {
+
+    DocumentGroupService.Iface client = getClient();
+
+    DocumentRecord primeDocRecord = new DocumentRecord();
+    primeDocRecord.setId("prime-id1");
+    Document primeDocument = new Document();
+    primeDocument.addToFields(new StringField("test", "test"));
+    primeDocRecord.setDocument(primeDocument);
+
+    DocumentRecord docRecord1 = new DocumentRecord();
+    docRecord1.setId("id1");
+    Document document1 = new Document();
+    document1.addToFields(new StringField("test", "test1"));
+    docRecord1.setDocument(document1);
+
+    DocumentRecord docRecord2 = new DocumentRecord();
+    docRecord2.setId("id1");
+    Document document2 = new Document();
+    document2.addToFields(new StringField("test", "test2"));
+    docRecord2.setDocument(document2);
+
+    DocumentGroup group = new DocumentGroup();
+    group.setId("group-id1");
+    group.setPrimeDoc(primeDocRecord);
+    group.addToDocuments(docRecord1);
+    group.addToDocuments(docRecord2);
+
+    client.updateGroup("t1", group);
+
+    DocumentGroupResult result = client.searchGroups("t1", "+super:<test:test1> +super:<test:test2>");
+    System.out.println("Total Hits:" + result.getTotalHits());
+    List<DocumentGroup> documents = result.getDocuments();
+    List<Double> scores = result.getScores();
+    for (int i = 0; i < documents.size(); i++) {
+      DocumentGroup documentGroup = documents.get(i);
+      Double score = scores.get(i);
+      System.out.println("Score :" + score);
+      System.out.println("Doc   :" + documentGroup);
+    }
+
+    client.deleteGroup("t1", "id1");
+
+  }
+
+  private static Iface getClient() {
+    return null;
+  }
+
+}


Mime
View raw message