Sorting on a Field that does not exist

Sometimes I need to sort on a field that doesn't exist. I of course
do not know it doesn't exist until runtime.

I tried the following

FieldSortBuilder sb = new
FieldSortBuilder(sortbyArr[0].toLowerCase());
sb.missing(null);
sb.order(sortbyArr.length>1 &&
sortbyArr[1].equalsIgnoreCase("desc") ?
SortOrder.DESC : SortOrder.ASC);
srb.addSort(sb);

I have sett the midding() to other values but it doesn't work because
my field is a String and ElasticSearch complains.
srb is the SearchRequestBuilder

We are replacing Lucene with ElasticSearch. In Lucene this worked for
us as we would construct the SortField Object and add that to the
query.

How can I make this work?

Sorting on a field that does not exists (in the mappings) will fail,
because elasticsearch needs to use the relevant sorting implementation
(numerics, string, ...).

On Tue, Nov 8, 2011 at 11:38 PM, LORDs_diakonos jasontesser@gmail.comwrote:

Sometimes I need to sort on a field that doesn't exist. I of course
do not know it doesn't exist until runtime.

I tried the following

FieldSortBuilder sb = new
FieldSortBuilder(sortbyArr[0].toLowerCase());
sb.missing(null);
sb.order(sortbyArr.length>1 &&
sortbyArr[1].equalsIgnoreCase("desc") ?
SortOrder.DESC : SortOrder.ASC);
srb.addSort(sb);

I have sett the midding() to other values but it doesn't work because
my field is a String and Elasticsearch complains.
srb is the SearchRequestBuilder

We are replacing Lucene with Elasticsearch. In Lucene this worked for
us as we would construct the SortField Object and add that to the
query.

How can I make this work?

so 2 questions then

  1. Is there a problem with having tons and tons of fields cause I would
    have to generate thousands or 10s of thousands of fields and set many to
    null ro fix my issue.

  2. Is there a speedy way to check for fields that exist so I know what to
    sort on?

Thanks,
Jason Tesser
dotCMS Director, Support Services
1-305-858-1422

On Wed, Nov 9, 2011 at 6:16 AM, Shay Banon kimchy@gmail.com wrote:

Sorting on a field that does not exists (in the mappings) will fail,
because elasticsearch needs to use the relevant sorting implementation
(numerics, string, ...).

On Tue, Nov 8, 2011 at 11:38 PM, LORDs_diakonos jasontesser@gmail.comwrote:

Sometimes I need to sort on a field that doesn't exist. I of course
do not know it doesn't exist until runtime.

I tried the following

FieldSortBuilder sb = new
FieldSortBuilder(sortbyArr[0].toLowerCase());
sb.missing(null);
sb.order(sortbyArr.length>1 &&
sortbyArr[1].equalsIgnoreCase("desc") ?
SortOrder.DESC : SortOrder.ASC);
srb.addSort(sb);

I have sett the midding() to other values but it doesn't work because
my field is a String and Elasticsearch complains.
srb is the SearchRequestBuilder

We are replacing Lucene with Elasticsearch. In Lucene this worked for
us as we would construct the SortField Object and add that to the
query.

How can I make this work?

Not sure I understand..., are the fields supposed to be in this type or
not? You can use get mapping for a specific index/type, and see which
fields are currently mapped in the index.

On Wed, Nov 9, 2011 at 1:50 PM, Jason Tesser jasontesser@gmail.com wrote:

so 2 questions then

  1. Is there a problem with having tons and tons of fields cause I would
    have to generate thousands or 10s of thousands of fields and set many to
    null ro fix my issue.

  2. Is there a speedy way to check for fields that exist so I know what to
    sort on?

Thanks,
Jason Tesser
dotCMS Director, Support Services
1-305-858-1422

On Wed, Nov 9, 2011 at 6:16 AM, Shay Banon kimchy@gmail.com wrote:

Sorting on a field that does not exists (in the mappings) will fail,
because elasticsearch needs to use the relevant sorting implementation
(numerics, string, ...).

On Tue, Nov 8, 2011 at 11:38 PM, LORDs_diakonos jasontesser@gmail.comwrote:

Sometimes I need to sort on a field that doesn't exist. I of course
do not know it doesn't exist until runtime.

I tried the following

FieldSortBuilder sb = new
FieldSortBuilder(sortbyArr[0].toLowerCase());
sb.missing(null);
sb.order(sortbyArr.length>1 &&
sortbyArr[1].equalsIgnoreCase("desc") ?
SortOrder.DESC : SortOrder.ASC);
srb.addSort(sb);

I have sett the midding() to other values but it doesn't work because
my field is a String and Elasticsearch complains.
srb is the SearchRequestBuilder

We are replacing Lucene with Elasticsearch. In Lucene this worked for
us as we would construct the SortField Object and add that to the
query.

How can I make this work?