Indexing fields without storing using Java API

I want to just index all of the fields without storing them.
How?

bulkRequest.add(client.prepareIndex("sponge2", "153299", "ID")
.setSource(jsonBuilder()
.startObject()
.field("hostname", hostName2)
.field("logtype", logType2)
.field("env", env2)
.field("logpath", logPath2)
.field("logfilename", logFileName2)
.field("timestamp", timeStamp)
.field("eventbody", sCurrentLine)
.endObject()
)
);
I want "hostname","logtype","env","logpath","logfilename","timestamp"
and "eventbody" indexed but not stored.
And later I use these field as filters just get the "ID".

--

Acutally, it may not be necessary to use "source".
I just want to index all the fields and later I search them with a
unique ID.
I'm new to search. Maybe it's stupid question.

On 10月12日, 上午11时22分, dean elasticbet...@gmail.com wrote:

I want to just index all of the fields without storing them.
How?

bulkRequest.add(client.prepareIndex("sponge2", "153299", "ID")
.setSource(jsonBuilder()
.startObject()
.field("hostname", hostName2)
.field("logtype", logType2)
.field("env", env2)
.field("logpath", logPath2)
.field("logfilename", logFileName2)
.field("timestamp", timeStamp)
.field("eventbody", sCurrentLine)
.endObject()
)
);
I want "hostname","logtype","env","logpath","logfilename","timestamp"
and "eventbody" indexed but not stored.
And later I use these field as filters just get the "ID".

--

I'm new to search. Maybe it's a stupid question.
Actually, I want all the fields indexed to be searchable later.
Then I just get the id by filtering those fields.
Maybe "ID" is not nessary because I see there is a setID method.
What's the differences?

On 10月12日, 上午11时22分, dean elasticbet...@gmail.com wrote:

I want to just index all of the fields without storing them.
How?

bulkRequest.add(client.prepareIndex("sponge2", "153299", "ID")
.setSource(jsonBuilder()
.startObject()
.field("hostname", hostName2)
.field("logtype", logType2)
.field("env", env2)
.field("logpath", logPath2)
.field("logfilename", logFileName2)
.field("timestamp", timeStamp)
.field("eventbody", sCurrentLine)
.endObject()
)
);
I want "hostname","logtype","env","logpath","logfilename","timestamp"
and "eventbody" indexed but not stored.
And later I use these field as filters just get the "ID".

--

Dean,

You're going to need to define a mapping for your fields, setting stored to
false on those fields you dont want stored.. See

and Elasticsearch Platform — Find real-time answers at scale | Elastic for
some details.

On Friday, October 12, 2012 4:22:39 PM UTC+13, dean wrote:

I want to just index all of the fields without storing them.
How?

bulkRequest.add(client.prepareIndex("sponge2", "153299", "ID")
.setSource(jsonBuilder()
.startObject()
.field("hostname",
hostName2)
.field("logtype",
logType2)
.field("env",
env2)
.field("logpath",
logPath2)

.field("logfilename", logFileName2)

.field("timestamp", timeStamp)

.field("eventbody", sCurrentLine)
.endObject()
)
);
I want "hostname","logtype","env","logpath","logfilename","timestamp"
and "eventbody" indexed but not stored.
And later I use these field as filters just get the "ID".

--

You are already there in building the data for a document, similar to that you have to build mappings as informed by Chris Male.

You can do that as below: (make sure index is already created before executing this request, and _source field is disabled as below.)
XContentBuilder data = XContentFactory.jsonBuilder().startObject()
.startObject("settings")
.startObject("_source")
.field("enabled", false)
.endObject()
.startObject("properties")
.startObject("content0")
.field("type", "string")
.endObject()
.startObject("content1")
.field("type", "string")
.field("store", "no")
.endObject()
.endObject().endObject()
.endObject();

		PutMappingRequest putMappingRequest = new PutMappingRequest(
				"dean_index");
		putMappingRequest.type("dean_type");
		putMappingRequest.source(<b>data</b>);
		PutMappingResponse putMappingResponse = client.admin().indices()
				.putMapping(putMappingRequest).actionGet();
		putMappingResponse.acknowledged();

FYI. By default Elasticsearch doesn't store.

Hey,

by default only _source is stored, other fields are not stored by default.
so in your case you can simply set "_source" : {"store" : false} via the
mapping API when you create the index. here are some more details:

source
field: Elasticsearch Platform — Find real-time answers at scale | Elastic
create index with
mapping: Elasticsearch Platform — Find real-time answers at scale | Elastic
(see the mapping part here)

simon

On Friday, October 12, 2012 6:08:51 AM UTC+2, Chris Male wrote:

Dean,

You're going to need to define a mapping for your fields, setting stored
to false on those fields you dont want stored.. See
Elasticsearch Platform — Find real-time answers at scale | Elastic
and Elasticsearch Platform — Find real-time answers at scale | Elastic for
some details.

On Friday, October 12, 2012 4:22:39 PM UTC+13, dean wrote:

I want to just index all of the fields without storing them.
How?

bulkRequest.add(client.prepareIndex("sponge2", "153299", "ID")
.setSource(jsonBuilder()
.startObject()

.field("hostname", hostName2)
.field("logtype",
logType2)
.field("env",
env2)
.field("logpath",
logPath2)

.field("logfilename", logFileName2)

.field("timestamp", timeStamp)

.field("eventbody", sCurrentLine)
.endObject()
)
);
I want "hostname","logtype","env","logpath","logfilename","timestamp"
and "eventbody" indexed but not stored.
And later I use these field as filters just get the "ID".

--

Thank all you guys.
Your help is very valuable to me.
Pounraj's source is just what I want.

在 2012年10月12日星期五UTC+8下午3时09分34秒,Manikandan Pounraj写道:

You are already there in building the data for a document, similar to that
you have to build mappings as informed by Chris Male.

You can do that as below: (make sure index is already created before
executing this request, and _source field is disabled as below.)
XContentBuilder data =
XContentFactory.jsonBuilder().startObject()
.startObject("settings")
.startObject("
_source
")
.field*("enabled", false)*
.endObject()
.startObject("properties")
.startObject("content0")
.field("type", "string")
.endObject()
.startObject("content1")
.field("type", "string")
.field*("store", "no")*
.endObject()
.endObject().endObject()
.endObject();

                    PutMappingRequest putMappingRequest = new 

PutMappingRequest(
"dean_index");
putMappingRequest.type("dean_type");
putMappingRequest.source(data);
PutMappingResponse putMappingResponse =
client.admin().indices()
.putMapping(putMappingRequest).actionGet();

                    putMappingResponse.acknowledged(); 

FYI. By default Elasticsearch doesn't store.

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Indexing-fields-without-storing-using-Java-API-tp4023858p4023868.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--