/** * Sets the artificial document from which to generate term vectors. */ public TermVectorsRequestBuilder setDoc(XContentBuilder xContent) { request.doc(xContent); return this; }
/** * Sets an artificial document from which term vectors are requested for. * @deprecated use {@link #doc(BytesReference, boolean, XContentType)} to avoid content auto detection */ @Deprecated public TermVectorsRequest doc(BytesReference doc, boolean generateRandomId) { return this.doc(doc, generateRandomId, XContentHelper.xContentType(doc)); }
/** * Sets an artificial document from which term vectors are requested for. */ public TermVectorsRequest doc(XContentBuilder documentBuilder) { return this.doc(BytesReference.bytes(documentBuilder), true, documentBuilder.contentType()); }
/** * Sets the artificial document from which to generate term vectors. */ public TermVectorsRequestBuilder setDoc(XContentBuilder xContent) { request.doc(xContent); return this; }
/** * Constructs a new term vector request for a document that will be fetch * from the provided index. Use {@link #type(String)} and * {@link #id(String)} to specify the document to load. */ public TermVectorsRequest(TermVectorsRequest other) { super(other.index()); this.id = other.id(); this.type = other.type(); if (other.doc != null) { this.doc = new BytesArray(other.doc().toBytesRef(), true); this.xContentType = other.xContentType; } this.flagsEnum = other.getFlags().clone(); this.preference = other.preference(); this.routing = other.routing(); this.parent = other.parent(); if (other.selectedFields != null) { this.selectedFields = new HashSet<>(other.selectedFields); } if (other.perFieldAnalyzer != null) { this.perFieldAnalyzer = new HashMap<>(other.perFieldAnalyzer); } this.realtime = other.realtime(); this.version = other.version(); this.versionType = VersionType.fromValue(other.versionType().getValue()); this.filterSettings = other.filterSettings(); }
/** * Sets the artificial document from which to generate term vectors. */ public TermVectorsRequestBuilder setDoc(XContentBuilder xContent) { request.doc(xContent); return this; }
/** * Sets the artificial document from which to generate term vectors. */ public TermVectorsRequestBuilder setDoc(XContentBuilder xContent) { request.doc(xContent); return this; }
private static Fields generateTermVectorsFromDoc(IndexShard indexShard, TermVectorsRequest request) throws IOException { // parse the document, at the moment we do update the mapping, just like percolate ParsedDocument parsedDocument = parseDocument(indexShard, indexShard.shardId().getIndexName(), request.type(), request.doc(), request.xContentType()); // select the right fields and generate term vectors ParseContext.Document doc = parsedDocument.rootDoc(); Set<String> seenFields = new HashSet<>(); Collection<DocumentField> documentFields = new HashSet<>(); for (IndexableField field : doc.getFields()) { MappedFieldType fieldType = indexShard.mapperService().fullName(field.name()); if (!isValidField(fieldType)) { continue; } if (request.selectedFields() != null && !request.selectedFields().contains(field.name())) { continue; } if (seenFields.contains(field.name())) { continue; } else { seenFields.add(field.name()); } String[] values = doc.getValues(field.name()); documentFields.add(new DocumentField(field.name(), Arrays.asList((Object[]) values))); } return generateTermVectors(indexShard, XContentHelper.convertToMap(parsedDocument.source(), true, request.xContentType()).v2(), documentFields, request.offsets(), request.perFieldAnalyzer(), seenFields); }
@Override protected ShardIterator shards(ClusterState state, InternalRequest request) { if (request.request().doc() != null && request.request().routing() == null) { // artificial document without routing specified, ignore its "id" and use either random shard or according to preference GroupShardsIterator<ShardIterator> groupShardsIter = clusterService.operationRouting().searchShards(state, new String[] { request.concreteIndex() }, null, request.request().preference()); return groupShardsIter.iterator().next(); } return clusterService.operationRouting().getShards(state, request.concreteIndex(), request.request().id(), request.request().routing(), request.request().preference()); }
/** * Convert this to a {@link TermVectorsRequest} for fetching the terms of the document. */ TermVectorsRequest toTermVectorsRequest() { TermVectorsRequest termVectorsRequest = new TermVectorsRequest(index, type, id) .selectedFields(fields) .routing(routing) .version(version) .versionType(versionType) .perFieldAnalyzer(perFieldAnalyzer) .positions(false) // ensures these following parameters are never set .offsets(false) .payloads(false) .fieldStatistics(false) .termStatistics(false); // for artificial docs to make sure that the id has changed in the item too if (doc != null) { termVectorsRequest.doc(doc, true, xContentType); this.id = termVectorsRequest.id(); } return termVectorsRequest; }
"either [id] or [doc] can be specified, but not both!"); termVectorsRequest.doc(jsonBuilder().copyCurrentStructure(parser)); } else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) { termVectorsRequest.routing = parser.text();
/** * Sets an artificial document from which term vectors are requested for. * @deprecated use {@link #doc(BytesReference, boolean, XContentType)} to avoid content auto detection */ @Deprecated public TermVectorsRequest doc(BytesReference doc, boolean generateRandomId) { return this.doc(doc, generateRandomId, XContentHelper.xContentType(doc)); }
/** * Sets an artificial document from which term vectors are requested for. * @deprecated use {@link #doc(BytesReference, boolean, XContentType)} to avoid content auto detection */ @Deprecated public TermVectorsRequest doc(BytesReference doc, boolean generateRandomId) { return this.doc(doc, generateRandomId, XContentFactory.xContentType(doc)); }
/** * Sets an artificial document from which term vectors are requested for. */ public TermVectorsRequest doc(XContentBuilder documentBuilder) { return this.doc(documentBuilder.bytes(), true); }
/** * Sets an artificial document from which term vectors are requested for. */ public TermVectorsRequest doc(XContentBuilder documentBuilder) { return this.doc(BytesReference.bytes(documentBuilder), true, documentBuilder.contentType()); }
/** * Sets an artificial document from which term vectors are requested for. */ public TermVectorsRequest doc(XContentBuilder documentBuilder) { return this.doc(documentBuilder.bytes(), true, documentBuilder.contentType()); }
DocIdAndVersion docIdAndVersion = get.docIdAndVersion(); if (request.doc() != null) { termVectorsByField = generateTermVectorsFromDoc(indexShard, request);
@Override protected ShardIterator shards(ClusterState state, InternalRequest request) { if (request.request().doc() != null && request.request().routing() == null) { // artificial document without routing specified, ignore its "id" and use either random shard or according to preference GroupShardsIterator<ShardIterator> groupShardsIter = clusterService.operationRouting().searchShards(state, new String[] { request.concreteIndex() }, null, request.request().preference()); return groupShardsIter.iterator().next(); } return clusterService.operationRouting().getShards(state, request.concreteIndex(), request.request().id(), request.request().routing(), request.request().preference()); }
@Override protected ShardIterator shards(ClusterState state, InternalRequest request) { if (request.request().doc() != null && request.request().routing() == null) { // artificial document without routing specified, ignore its "id" and use either random shard or according to preference GroupShardsIterator<ShardIterator> groupShardsIter = clusterService.operationRouting().searchShards(state, new String[] { request.concreteIndex() }, null, request.request().preference()); return groupShardsIter.iterator().next(); } return clusterService.operationRouting().getShards(state, request.concreteIndex(), request.request().id(), request.request().routing(), request.request().preference()); }
@Override protected ShardIterator shards(ClusterState state, InternalRequest request) { if (request.request().doc() != null && request.request().routing() == null) { // artificial document without routing specified, ignore its "id" and use either random shard or according to preference GroupShardsIterator<ShardIterator> groupShardsIter = clusterService.operationRouting().searchShards(state, new String[] { request.concreteIndex() }, null, request.request().preference()); return groupShardsIter.iterator().next(); } return clusterService.operationRouting().getShards(state, request.concreteIndex(), request.request().id(), request.request().routing(), request.request().preference()); }