Package org.elasticsearch.common.xcontent

Examples of org.elasticsearch.common.xcontent.XContentBuilder.string()


    try {
      Logger.debug("Create Elastic Search Type %s/%s", indexName, typeName);
      PutMappingRequest request = Requests.putMappingRequest(indexName).type(typeName);
      XContentBuilder mapping = MappingUtil.getMapping(mapper);
      Logger.debug("Type mapping: \n %s", mapping.string());
      request.source(mapping);
      PutMappingResponse response = client.admin().indices().putMapping(request).actionGet();
      Logger.debug("Response: %s", response);

    } catch (IndexAlreadyExistsException iaee) {
View Full Code Here


      String documentId = mapper.getDocumentId(model);
      Logger.debug("Index Name: %s", indexName);

      contentBuilder = XContentFactory.jsonBuilder().prettyPrint();
      mapper.addModel(model, contentBuilder);
      Logger.debug("Index json: %s", contentBuilder.string());
      IndexResponse response = client.prepareIndex(indexName, typeName, documentId)
          .setSource(contentBuilder).execute().actionGet();

      // Log Debug
      Logger.info("Index Response: %s", response);
View Full Code Here

    mapping.endObject();
    mapping.endObject();
    mapping.endObject();

    assertEquals(mapping.string(), generatedMapping.string());
  }

}
View Full Code Here

            XContentBuilder builder = XContentFactory.jsonBuilder();
            builder.startObject();
            toXContent.toXContent(builder, SearchResponse.EMPTY_PARAMS);
            builder.endObject();

            JsonObject response = new JsonObject(builder.string());
            sendOK(message, response);

        } catch (IOException e) {
            sendError(message, "Error reading search response: " + e.getMessage(), e);
        }
View Full Code Here

            XContentBuilder builder = XContentFactory.jsonBuilder();
            builder.startObject();
            toXContent.toXContent(builder, SearchResponse.EMPTY_PARAMS);
            builder.endObject();

            JsonObject response = new JsonObject(builder.string());
            sendOK(message, response);

        } catch (IOException e) {
            sendError(message, "Error reading search response: " + e.getMessage(), e);
        }
View Full Code Here

        builder.endObject();
      }
      builder.endArray();
    }
    builder.endObject();
    return builder.string();
  }

  /**
   * @param spaceKey to get info for
   * @return spaces indexing info or null if not found.
View Full Code Here

        contentBuilder.startObject();
        mapperBuilder.build(new BuilderContext(null, new ContentPath())).toXContent(contentBuilder, null);
        contentBuilder.endObject();

        // cache mapping as string for easy debugging
        _mapping = contentBuilder.string();
      }
      return MappingSource.Builder.string(_mapping);
    } catch (IOException e) {
      throw new RuntimeException();
    }
View Full Code Here

              }
            });
        contentBuilder.endObject();

        // cache mapping as string for easy debugging
        _mapping = contentBuilder.string();
      }
      return MappingSource.Builder.string(_mapping);
    } catch (IOException e) {
      throw new RuntimeException();
    }
View Full Code Here

        XContentBuilder builder = XContentFactory.contentBuilder(
                XContentType.JSON).startObject();
        facet.toXContent(builder, ToXContent.EMPTY_PARAMS).endObject();

        assertThat(builder.string(), equalTo(expected));

    }

}
View Full Code Here

        XContentBuilder builder = XContentFactory.contentBuilder(
                XContentType.JSON).startObject();
        facet.toXContent(builder, ToXContent.EMPTY_PARAMS).endObject();

        assertThat(builder.string(), equalTo(expected));
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.