How to hide some fields in _store using mappings

Hi,

I was my once again copy & paste mistake.

{
"order_template" : {
"template" : "",
"order": 0,
"settings" :{
},
"mappings" : {
"default" : {
"_source" : {
"includes": ["
"],
"excludes": ["data"]
}
}
}
}
}

it is the data field, which was in "excludes" list, able to search first
time on the "data" field, but after updating, not able to search on the
"data" field.

I am sorry, once again for the confusion.

Regards,
Akram.

On Friday, November 22, 2013 11:30:33 PM UTC+5:30, Ivan Brusic wrote:

I do not see the issue on 0.90.5. After an update I can no longer search
against the "text" field, but "data" works fine.

On Fri, Nov 22, 2013 at 9:55 AM, Akram Hussain <akram.hu...@gmail.com<javascript:>

wrote:

Hi,

yes, I have missed the line, the code is, as it was returned from other
method, I missed it.

SearchRequestBuilder builder = client.prepareSearch(
searchContext.getIndexName()).setSearchType(SearchType.DFS_
QUERY_THEN_FETCH)
.setFrom(searchContext.getOffset()).setSize(searchContext.getSize());
QueryBuilder queryBuilder = QueryBuilders.matchPhrasePrefixQuery("data",
"dataValue");

builder.setQuery(QueryBuilders.constantScoreQuery(
FilterBuilders.queryFilter(queryBuilder)));

The missed line is the bold line, it will search on "data" field itself,
after updating/adding new fields to the source, the field "data" is getting
lost from source.

Let me know the possible ways to handle it.

Regards,
Akram.

On Friday, November 22, 2013 11:14:36 PM UTC+5:30, Ivan Brusic wrote:

In your query code, you posted everything except the actual query! Which
field are you searching against? You mention that the data field is lost,
but you are excluding the text field. Typo?

I never exclude fields in source, but it seems like a field is required
if you want to search against it. It works after indexing, but will
disappear after updating. I doubt that is a bug, since elasticsearch has
nothing to update. An update basically is an atomic delete/insert.

Cheers,

Ivan

On Thu, Nov 21, 2013 at 8:21 PM, Akram Hussain akram.hu...@gmail.comwrote:

Hi,

The following one is my template

{

  • "order_template" : {*
  • "template" : "",
  • "order": 0,*
  • "settings" :{*
  • },*
  • "mappings" : {*
  • "default" : {*
  • "_source" : {*
  • "includes": [""],
  • "excludes": ["text"]*
  • }*
  • }*
  • }*
  • }*
    }

I am fetching the results using

SearchRequestBuilder builder =
client.prepareSearch(searchContext.getIndexName()).setSearchType(SearchType.DFS_QUERY_THEN_FETCH)

  • .setFrom(searchContext.getOffset()).setSize(searchContext.getSize());*

builder.setQuery(QueryBuilders.constantScoreQuery(FilterBuilders.queryFilter(queryBuilder)));

but updating is being done by following api

StringBuilder scriptBuilder = new StringBuilder();

scriptBuilder.append("ctx._source.").append("assigned").append("=").append("value");
client.prepareUpdate(index, type,
id).setScript(scriptBuilder.toString());

after updating with above api, the hidden field, i.e, *data *field is
lost.

I am doing any thing wrong while using api's.

Regards
Akram.

On Thursday, November 21, 2013 11:28:58 PM UTC+5:30, Ivan Brusic wrote:

It would help if you provided your mapping and an example query. Are
you searching against a certain field, the data field, or the _all field?
Create a gist as described here: Elasticsearch Platform — Find real-time answers at scale | Elastichttp://www.google.com/url?q=http%3A%2F%2Fwww.elasticsearch.org%2Fhelp%2F&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNGgo5_ert12o9OPxq7NdLYIOQ5Nig It
would help to retrieve the current mapping via the API, because some times
the mapping that is in effect might not be identical to the one you
supplied. :slight_smile:

One issue to point out, in case it was not understood, is that some
updates to the mapping will not affect documents that are currently
indexed. How are you adding fields to a document? Are you reindexing or
using the update API?

Cheers,

Ivan

On Thu, Nov 21, 2013 at 4:57 AM, Akram Hussain akram.hu...@gmail.comwrote:

Hi,

Thanks for the reply.

It worked, but failed when try to add some other new fields to the
source from java api.

I have template like this

"mappings" : {
"default" : {
"_source" : {
"includes": ["*"],
"excludes": ["data"]
}
}
}

where only data field should be hidden, but it should be searchable.

  1. With the template I have created the doc like {"data" : "dataone",
    "config": "config data", "status": "fine"}.
  2. When I searched for "dataone" using java api, it returned the
    correct data, with remaining fields displayed not displaying "data" field - it
    is fine
    .
  3. To the ssme document added some other fields like "assigned", etc
  • They were added to document.
  1. But when I searched once again for "dataone" using java api, now
    the search is not returning the data.

how to make "data" field, should not be lost after updated - I guess
it lost but not sure, but not returning in the search result at second
time).

Regards,
Akram.

On Thursday, November 21, 2013 1:58:39 PM UTC+5:30, Hannes Korte
wrote:

Hi Akram,

besides the solution of storing each field individually, you could
as
well include and exclude certain fields in the source:

"_source" : {
"includes" : ["timestamp", "title", "tinyfields."],
"excludes" : ["largefields.
"]
}

Elasticsearch Platform — Find real-time answers at scale | Elastic
e/current/mapping-source-field.htmlhttp://www.google.com/url?q=http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fcurrent%2Fmapping-source-field.html&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNE15ilwN5QEN-j9w-sjFFzjpz0dUA

Best regards,
Hannes

On 20.11.2013 17:39, Akram Hussain wrote:

Hi,

I have some data, which should be hidden/not displayed as part of
the
_source.

when I set _source : { enabled : false}, source is being returned
as null.

How to make some fields are not displayed, but display _source.

Regards,
Akram.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to elasticsearc...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.