Java Code Examples for org.apache.solr.common.SolrInputDocument#getField()

The following examples show how to use org.apache.solr.common.SolrInputDocument#getField() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testBooleanValuesInAdd() throws Exception {
  String str = "{'add':[{'id':'1','b1':true,'b2':false,'b3':[false,true]}]}".replace('\'', '"');
  SolrQueryRequest req = req();
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals(1, p.addCommands.size());

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField("b1");
  assertEquals(Boolean.TRUE, f.getValue());
  f = d.getField("b2");
  assertEquals(Boolean.FALSE, f.getValue());
  f = d.getField("b3");
  assertEquals(2, ((List)f.getValue()).size());
  assertEquals(Boolean.FALSE, ((List)f.getValue()).get(0));
  assertEquals(Boolean.TRUE, ((List)f.getValue()).get(1));

  req.close();
}
 
Example 2
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testIntegerValuesInAdd() throws Exception {
  String str = "{'add':[{'id':'1','i1':256,'i2':-5123456789,'i3':[0,1]}]}".replace('\'', '"');
  SolrQueryRequest req = req();
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals(1, p.addCommands.size());

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField("i1");
  assertEquals(256L, f.getValue());
  f = d.getField("i2");
  assertEquals(-5123456789L, f.getValue());
  f = d.getField("i3");
  assertEquals(2, ((List)f.getValue()).size());
  assertEquals(0L, ((List)f.getValue()).get(0));
  assertEquals(1L, ((List)f.getValue()).get(1));

  req.close();
}
 
Example 3
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDecimalValuesInAdd() throws Exception {
  String str = "{'add':[{'id':'1','d1':256.78,'d2':-5123456789.0,'d3':0.0,'d3':1.0,'d4':1.7E-10}]}".replace('\'', '"');
  SolrQueryRequest req = req();
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals(1, p.addCommands.size());

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField("d1");
  assertEquals(256.78, f.getValue());
  f = d.getField("d2");
  assertEquals(-5123456789.0, f.getValue());
  f = d.getField("d3");
  assertEquals(2, ((List)f.getValue()).size());
  assertTrue(((List)f.getValue()).contains(0.0));
  assertTrue(((List) f.getValue()).contains(1.0));
  f = d.getField("d4");
  assertEquals(1.7E-10, f.getValue());

  req.close();
}
 
Example 4
Source Project: lucene-solr   File: SolrLogPostToolTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateRecords() throws Exception{
  String record = "2019-12-25 20:38:23.498 INFO  (qtp2103763750-126) [c:logs3 s:shard1 r:core_node2 x:logs3_shard1_replica_n1] o.a.s.u.p.LogUpdateProcessorFactory [logs3_shard1_replica_n1]  webapp=/solr path=/update params={commitWithin=1000&overwrite=true&wt=json&_=1577306114481}{deleteByQuery=*:* (-1653925534487281664)} 0 11\n" +
                  "2019-12-25 20:42:13.411 INFO  (qtp2103763750-303) [c:logs5 s:shard1 r:core_node2 x:logs5_shard1_replica_n1] o.a.s.u.p.LogUpdateProcessorFactory [logs5_shard1_replica_n1]  webapp=/solr path=/update params={commitWithin=1000&overwrite=true&wt=json&_=1577306114481}{delete=[03bbe975-728a-4df8-aa25-fe25049dc0ef (-1653925775577972736)]} 0 1\n";
  List<SolrInputDocument> docs = readDocs(record);
  assertEquals(docs.size(), 2);
  SolrInputDocument doc = docs.get(0);
  SolrInputField date = doc.getField("date_dt");
  SolrInputField type = doc.getField("type_s");
  SolrInputField core = doc.getField("core_s");
  SolrInputField collection = doc.getField("collection_s");
  assertEquals(date.getValue(), "2019-12-25T20:38:23.498");
  assertEquals(type.getValue(), "deleteByQuery");
  assertEquals(collection.getValue(), "logs3");
  assertEquals(core.getValue(), "logs3_shard1_replica_n1");

  SolrInputDocument doc1 = docs.get(1);
  SolrInputField date1 = doc1.getField("date_dt");
  SolrInputField type1 = doc1.getField("type_s");
  SolrInputField core1 = doc1.getField("core_s");
  SolrInputField collection1= doc1.getField("collection_s");
  assertEquals(date1.getValue(), "2019-12-25T20:42:13.411");
  assertEquals(type1.getValue(), "delete");
  assertEquals(collection1.getValue(), "logs5");
  assertEquals(core1.getValue(), "logs5_shard1_replica_n1");
}
 
Example 5
Source Project: lucene-solr   File: SolrLogPostToolTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCommit() throws Exception{
  String record = "2019-12-16T14:20:19.708 INFO  (qtp812143047-22671) [c:production_201912 s:shard128 r:core_node7 x:production_201912_shard128_replica] o.a.s.u.DirectUpdateHandler2 start commit{_version_=1653086376121335808,optimize=false,openSearcher=true,waitSearcher=true,expungeDeletes=false,softCommit=false,prepareCommit=false}\n";
  List<SolrInputDocument> docs = readDocs(record);
  assertEquals(docs.size(), 1);
  SolrInputDocument doc = docs.get(0);

  SolrInputField date = doc.getField("date_dt");
  SolrInputField type = doc.getField("type_s");
  SolrInputField shard = doc.getField("shard_s");
  SolrInputField replica = doc.getField("replica_s");
  SolrInputField core = doc.getField("core_s");
  SolrInputField openSearcher = doc.getField("open_searcher_s");
  SolrInputField softCommit = doc.getField("soft_commit_s");
  SolrInputField collection = doc.getField("collection_s");

  assertEquals(date.getValue(), "2019-12-16T14:20:19.708");
  assertEquals(type.getValue(), "commit");
  assertEquals(shard.getValue(), "shard128");
  assertEquals(replica.getValue(), "core_node7");
  assertEquals(core.getValue(), "production_201912_shard128_replica");
  assertEquals(openSearcher.getValue(), "true");
  assertEquals(softCommit.getValue(), "false");
  assertEquals(collection.getValue(), "production_201912");
}
 
Example 6
@Override
public int compare(SolrInputDocument doc1, SolrInputDocument doc2) {
  SolrInputField f1 = doc1.getField(fieldName);
  SolrInputField f2 = doc2.getField(fieldName);
  if (f1 == f2) {
    return 0;
  } else if (f1 == null) {
    return -1;
  } else if (f2 == null) {
    return 1;
  }
  
  Object v1 = f1.getFirstValue();
  Object v2 = f2.getFirstValue();          
  return child.compare(v1, v2);
}
 
Example 7
private static RecordMutation createRecordMutation(SolrInputDocument doc, String id) {
  RecordMutation recordMutation = new RecordMutation();
  // TODO: what's solr default behavior?
  recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
  Record record = new Record();
  record.setFamily(findFamily(doc));
  record.setRecordId(id);

  for (String fieldName : doc.getFieldNames()) {
    if (!fieldName.contains(".")) {
      continue;
    }
    SolrInputField field = doc.getField(fieldName);
    String rawColumnName = fieldName.substring(fieldName.indexOf(".") + 1, fieldName.length());

    if (field.getValueCount() > 1) {
      for (Object fieldVal : field.getValues()) {
        record.addToColumns(new Column(rawColumnName, fieldVal.toString()));
      }
    } else {
      record.addToColumns(new Column(rawColumnName, field.getFirstValue().toString()));
    }
  }
  recordMutation.setRecord(record);
  return recordMutation;
}
 
Example 8
/**
 * Add a SolrInputDocument to this writer.
 * <p>
 * Adding multiple documents without ids will result in an IllegalStateException being thrown.
 */
@Override
public void add(SolrInputDocument solrDocument) {
    String docId = documentId;
    SolrInputField uniqueKeySolrField = solrDocument.getField(uniqueKeyField);
    if (uniqueKeySolrField == null) {
        if (idUsed) {
            throw new IllegalStateException("Document id '" + documentId + "' has already been used by this record");
        }
        solrDocument.addField(uniqueKeyField, documentId);
        idUsed = true;
    } else {
        docId = uniqueKeySolrField.getValue().toString();
    }
    
    if (tableNameField != null) {
        solrDocument.addField(tableNameField, tableName);
    }
    
    updateCollector.add(docId, solrDocument);
}
 
Example 9
@Test
// commented out on: 24-Dec-2018   @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 20-Sep-2018
public void testSimple() throws Exception {
  DocumentObjectBinder binder = new DocumentObjectBinder();
  XMLResponseParser parser = new XMLResponseParser();
  NamedList<Object> nl = parser.processResponse(new StringReader(xml));
  QueryResponse res = new QueryResponse(nl, null);

  SolrDocumentList solDocList = res.getResults();
  List<Item> l = binder.getBeans(Item.class,res.getResults());
  assertEquals(solDocList.size(), l.size());
  assertEquals(solDocList.get(0).getFieldValue("features"), l.get(0).features);

  Item item = new Item();
  item.id = "aaa";
  item.categories = new String[] {"aaa", "bbb", "ccc"};
  SolrInputDocument out = binder.toSolrInputDocument(item);

  assertEquals(item.id, out.getFieldValue("id"));
  SolrInputField catfield = out.getField("cat");
  assertEquals(3, catfield.getValueCount());

  @SuppressWarnings({"unchecked"})
  List<String> catValues = (List<String>) catfield.getValue();
  assertEquals("aaa", catValues.get(0));
  assertEquals("bbb", catValues.get(1));
  assertEquals("ccc", catValues.get(2));
}
 
Example 10
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testSimpleFormat() throws Exception
{
  String str = "[{'id':'1'},{'id':'2'}]".replace('\'', '"');
  SolrQueryRequest req = req("commitWithin","100", "overwrite","false");
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals( 2, p.addCommands.size() );

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField( "id" );
  assertEquals("1", f.getValue());
  assertEquals(add.commitWithin, 100);
  assertFalse(add.overwrite);

  add = p.addCommands.get(1);
  d = add.solrDoc;
  f = d.getField( "id" );
  assertEquals("2", f.getValue());
  assertEquals(add.commitWithin, 100);
  assertFalse(add.overwrite);

  req.close();
}
 
Example 11
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testSimpleFormatInAdd() throws Exception
{
  String str = "{'add':[{'id':'1'},{'id':'2'}]}".replace('\'', '"');
  SolrQueryRequest req = req();
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals( 2, p.addCommands.size() );

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField( "id" );
  assertEquals("1", f.getValue());
  assertEquals(add.commitWithin, -1);
  assertTrue(add.overwrite);

  add = p.addCommands.get(1);
  d = add.solrDoc;
  f = d.getField( "id" );
  assertEquals("2", f.getValue());
  assertEquals(add.commitWithin, -1);
  assertTrue(add.overwrite);

  req.close();
}
 
Example 12
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testBigDecimalValuesInAdd() throws Exception {
  String str = ("{'add':[{'id':'1','bd1':0.12345678901234567890123456789012345,"
               + "'bd2':12345678901234567890.12345678901234567890,'bd3':0.012345678901234567890123456789012345,"
               + "'bd3':123456789012345678900.012345678901234567890}]}").replace('\'', '"');
  SolrQueryRequest req = req();
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals(1, p.addCommands.size());

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField("bd1");                        
  assertTrue(f.getValue() instanceof String);
  assertEquals("0.12345678901234567890123456789012345", f.getValue());
  f = d.getField("bd2");
  assertTrue(f.getValue() instanceof String);
  assertEquals("12345678901234567890.12345678901234567890", f.getValue());
  f = d.getField("bd3");
  assertEquals(2, ((List)f.getValue()).size());
  assertTrue(((List)f.getValue()).contains("0.012345678901234567890123456789012345"));
  assertTrue(((List)f.getValue()).contains("123456789012345678900.012345678901234567890"));

  req.close();
}
 
Example 13
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testBigIntegerValuesInAdd() throws Exception {
  String str = ("{'add':[{'id':'1','bi1':123456789012345678901,'bi2':1098765432109876543210,"
               + "'bi3':[1234567890123456789012,10987654321098765432109]}]}").replace('\'', '"');
  SolrQueryRequest req = req();
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals(1, p.addCommands.size());

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField("bi1");
  assertTrue(f.getValue() instanceof String);
  assertEquals("123456789012345678901", f.getValue());
  f = d.getField("bi2");
  assertTrue(f.getValue() instanceof String);
  assertEquals("1098765432109876543210", f.getValue());
  f = d.getField("bi3");
  assertEquals(2, ((List)f.getValue()).size());
  assertTrue(((List)f.getValue()).contains("1234567890123456789012"));
  assertTrue(((List)f.getValue()).contains("10987654321098765432109"));

  req.close();
}
 
Example 14
Source Project: lucene-solr   File: JsonLoaderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testEmptyAnonymousChildDocs() throws Exception {
  String str = "{\n" +
      "    \"add\": {\n" +
      "        \"doc\": {\n" +
      "            \"id\": \"1\",\n" +
      "            \"_childDocuments_\": []\n" +
      "        }\n" +
      "    }\n" +
      "}";
  SolrQueryRequest req = req("commit","true");
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals( 1, p.addCommands.size() );

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField( "id" );
  assertEquals("1", f.getValue());
  List<SolrInputDocument> cd = d.getChildDocuments();
  assertNull(cd);

  req.close();
}
 
Example 15
Source Project: lucene-solr   File: SolrLogPostToolTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNewSearcher() throws Exception{
  String record = "2019-12-16 19:00:23.931 INFO  (searcherExecutor-66-thread-1) [   ] o.a.s.c.SolrCore [production_cv_month_201912_shard35_replica_n1] Registered new searcher [email protected][production_cv_month_201912_shard35_replica_n1] ...";
  List<SolrInputDocument> docs = readDocs(record);
  assertEquals(docs.size(), 1);
  SolrInputDocument doc = docs.get(0);
  SolrInputField date = doc.getField("date_dt");
  SolrInputField type = doc.getField("type_s");
  SolrInputField core = doc.getField("core_s");
  assertEquals(date.getValue(), "2019-12-16T19:00:23.931");
  assertEquals(type.getValue(), "newSearcher");
  assertEquals(core.getValue(), "production_cv_month_201912_shard35_replica_n1");
}
 
Example 16
Source Project: ranger   File: DbToSolrMigrationUtil.java    License: Apache License 2.0 5 votes vote down vote up
private void toSolrDocument(XXAccessAuditBase xXAccessAudit,  SolrInputDocument document) {
	// add v4 fields
	document.addField("id", xXAccessAudit.getId());
	document.addField("access", xXAccessAudit.getAccessType());
	document.addField("enforcer", xXAccessAudit.getAclEnforcer());
	document.addField("agent", xXAccessAudit.getAgentId());
	document.addField("repo", xXAccessAudit.getRepoName());
	document.addField("sess", xXAccessAudit.getSessionId());
	document.addField("reqUser", xXAccessAudit.getRequestUser());
	document.addField("reqData", xXAccessAudit.getRequestData());
	document.addField("resource", xXAccessAudit.getResourcePath());
	document.addField("cliIP", xXAccessAudit.getClientIP());
	document.addField("logType", "RangerAudit");
	document.addField("result", xXAccessAudit.getAccessResult());
	document.addField("policy", xXAccessAudit.getPolicyId());
	document.addField("repoType", xXAccessAudit.getRepoType());
	document.addField("resType", xXAccessAudit.getResourceType());
	document.addField("reason", xXAccessAudit.getResultReason());
	document.addField("action", xXAccessAudit.getAction());
	document.addField("evtTime", DateUtil.getLocalDateForUTCDate(xXAccessAudit.getEventTime()));
	SolrInputField idField = document.getField("id");
	boolean uidIsString = true;
	if( idField == null) {
		Object uid = null;
		if(uidIsString) {
			uid = UUID.randomUUID().toString();
		}
		document.setField("id", uid);
	}
}
 
Example 17
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  if (enabled) {
    SolrInputDocument doc = cmd.getSolrInputDocument();
    List<String> currDocSigFields = null;
    boolean isPartialUpdate = AtomicUpdateDocumentMerger.isAtomicUpdate(cmd);
    if (sigFields == null || sigFields.size() == 0) {
      if (isPartialUpdate)  {
        throw new SolrException
            (ErrorCode.SERVER_ERROR,
                "Can't use SignatureUpdateProcessor with partial updates on signature fields");
      }
      Collection<String> docFields = doc.getFieldNames();
      currDocSigFields = new ArrayList<>(docFields.size());
      currDocSigFields.addAll(docFields);
      Collections.sort(currDocSigFields);
    } else {
      currDocSigFields = sigFields;
    }

    Signature sig = req.getCore().getResourceLoader().newInstance(signatureClass, Signature.class);
    sig.init(params);

    for (String field : currDocSigFields) {
      SolrInputField f = doc.getField(field);
      if (f != null) {
        if (isPartialUpdate)  {
          throw new SolrException
              (ErrorCode.SERVER_ERROR,
                  "Can't use SignatureUpdateProcessor with partial update request " +
                      "containing signature field: " + field);
        }
        sig.add(field);
        Object o = f.getValue();
        if (o instanceof Collection) {
          for (Object oo : (Collection)o) {
            sig.add(String.valueOf(oo));
          }
        } else {
          sig.add(String.valueOf(o));
        }
      }
    }

    byte[] signature = sig.getSignature();
    char[] arr = new char[signature.length<<1];
    for (int i=0; i<signature.length; i++) {
      int b = signature[i];
      int idx = i<<1;
      arr[idx]= StrUtils.HEX_DIGITS[(b >> 4) & 0xf];
      arr[idx+1]= StrUtils.HEX_DIGITS[b & 0xf];
    }
    String sigString = new String(arr);
    doc.addField(signatureField, sigString);

    if (overwriteDupes) {
      cmd.updateTerm = new Term(signatureField, sigString);
    }

  }

  if (next != null)
    next.processAdd(cmd);
}
 
Example 18
/**
 * Tests the {@link DocumentAnalysisRequestHandler#resolveAnalysisRequest(org.apache.solr.request.SolrQueryRequest)}
 */
@Test
public void testResolveAnalysisRequest() throws Exception {

  String docsInput =
          "<docs>" +
                  "<doc>" +
                  "<field name=\"id\">1</field>" +
                  "<field name=\"whitetok\">The Whitetok</field>" +
                  "<field name=\"text\">The Text</field>" +
                  "</doc>" +
                  "</docs>";

  final ContentStream cs = new ContentStreamBase.StringStream(docsInput);
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.add("analysis.query", "The Query String");
  params.add("analysis.showmatch", "true");
  SolrQueryRequest req = new SolrQueryRequestBase(h.getCore(), params) {
    @Override
    public Iterable<ContentStream> getContentStreams() {
      return Collections.singleton(cs);
    }
  };

  DocumentAnalysisRequest request = handler.resolveAnalysisRequest(req);

  assertNotNull(request);
  assertTrue(request.isShowMatch());
  assertNotNull(request.getQuery());
  assertEquals("The Query String", request.getQuery());
  List<SolrInputDocument> documents = request.getDocuments();
  assertNotNull(documents);
  assertEquals(1, documents.size());
  SolrInputDocument document = documents.get(0);
  SolrInputField field = document.getField("id");
  assertNotNull(field);
  assertEquals("1", field.getFirstValue());
  field = document.getField("whitetok");
  assertNotNull(field);
  assertEquals("The Whitetok", field.getFirstValue());
  field = document.getField("text");
  assertNotNull(field);
  assertEquals("The Text", field.getFirstValue());

  req.close();
}
 
Example 19
Source Project: lucene-solr   File: SolrLogPostToolTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testQueryRecord() throws Exception{
  String record = "2019-12-09 15:05:01.931 INFO  (qtp2103763750-21) [c:logs4 s:shard1 r:core_node2 x:logs4_shard1_replica_n1] o.a.s.c.S.Request [logs4_shard1_replica_n1]  webapp=/solr path=/select params={q=*:*&_=1575835181759&shards.purpose=36&isShard=true&wt=javabin&distrib=false} hits=234868 status=0 QTime=8\n";
  List<SolrInputDocument> docs = readDocs(record);
  assertEquals(docs.size(), 1);
  SolrInputDocument doc = docs.get(0);

  SolrInputField query = doc.getField("q_s");
  SolrInputField date = doc.getField("date_dt");
  SolrInputField collection = doc.getField("collection_s");
  SolrInputField path = doc.getField("path_s");
  SolrInputField hits = doc.getField("hits_l");
  SolrInputField type = doc.getField("type_s");
  SolrInputField status = doc.getField("status_s");
  SolrInputField shard = doc.getField("shard_s");
  SolrInputField replica = doc.getField("replica_s");
  SolrInputField core = doc.getField("core_s");
  SolrInputField wt = doc.getField("wt_s");
  SolrInputField distrib = doc.getField("distrib_s");
  SolrInputField isShard = doc.getField("isShard_s");
  SolrInputField ids = doc.getField("ids_s");
  SolrInputField shards = doc.getField("shards_s");
  SolrInputField purpose = doc.getField("purpose_ss");
  Object[] purposes = purpose.getValues().toArray();

  assertEquals(query.getValue(), "*:*");
  assertEquals(date.getValue(), "2019-12-09T15:05:01.931");
  assertEquals(collection.getValue(), "logs4");
  assertEquals(path.getValue(), "/select");
  assertEquals(hits.getValue(), "234868");
  assertEquals(type.getValue(), "query");
  assertEquals(status.getValue(), "0");
  assertEquals(shard.getValue(), "shard1");
  assertEquals(replica.getValue(), "core_node2");
  assertEquals(core.getValue(), "logs4_shard1_replica_n1");
  assertEquals(wt.getValue(), "javabin");
  assertEquals(distrib.getValue(), "false");
  assertEquals(isShard.getValue(), "true");
  assertEquals(ids.getValue(), "false");
  assertEquals(shards.getValue(), "false");
  assertEquals("GET_TOP_IDS", purposes[0].toString());
  assertEquals("REFINE_FACETS", purposes[1].toString());
}
 
Example 20
Source Project: lucene-solr   File: SolrLogPostTool.java    License: Apache License 2.0 3 votes vote down vote up
private boolean isRTGRequest(SolrInputDocument doc) {
  final SolrInputField path = doc.getField("path_s");
  if (path == null) return false;


  return "/get".equals(path.getValue());
}