Native script doc() access problems

Hello,

I'm having a problem with a native script I'm currently working on. In the
start of the script I use doc().get() to access data and all is well.
However later on I try to access data again in the same manner (after an if
statement) and I get a blank value returned. If I try access these fields
from earlier on in the script all is well.

I was trying to only access certain fields in an if statement to keep the
amount of fields I accessed limited, but it seems that this won't work?

--

Could you post some code that would help us to reproduce the problem?

On Monday, October 29, 2012 4:33:06 PM UTC-4, William King wrote:

Hello,

I'm having a problem with a native script I'm currently working on. In the
start of the script I use doc().get() to access data and all is well.
However later on I try to access data again in the same manner (after an
if statement) and I get a blank value returned. If I try access these
fields from earlier on in the script all is well.

I was trying to only access certain fields in an if statement to keep the
amount of fields I accessed limited, but it seems that this won't work?

--

It's actually looking like the problem is something else entirely.

The script I'm running is within a "has_child" filter (not query) and it
looks like sometimes the filter is hitting the parent of the children that
I'm querying. So my previous diagnostic was completely off base. I'm
guessing this is the issue as I've been checking the doc.field("_id")
values of each document hit and the ones that are causing issues have
document IDs which correspond to the parent and not the child.

Is this behavior normal?

On Monday, October 29, 2012 2:57:54 PM UTC-7, Igor Motov wrote:

Could you post some code that would help us to reproduce the problem?

On Monday, October 29, 2012 4:33:06 PM UTC-4, William King wrote:

Hello,

I'm having a problem with a native script I'm currently working on. In
the start of the script I use doc().get() to access data and all is well.
However later on I try to access data again in the same manner (after an
if statement) and I get a blank value returned. If I try access these
fields from earlier on in the script all is well.

I was trying to only access certain fields in an if statement to keep the
amount of fields I accessed limited, but it seems that this won't work?

--

I am not sure which type of script you are running in your "has_child"
filter. Could you give an example of the query that you are executing?

On Monday, October 29, 2012 6:07:36 PM UTC-4, William King wrote:

It's actually looking like the problem is something else entirely.

The script I'm running is within a "has_child" filter (not query) and it
looks like sometimes the filter is hitting the parent of the children that
I'm querying. So my previous diagnostic was completely off base. I'm
guessing this is the issue as I've been checking the doc.field("_id")
values of each document hit and the ones that are causing issues have
document IDs which correspond to the parent and not the child.

Is this behavior normal?

On Monday, October 29, 2012 2:57:54 PM UTC-7, Igor Motov wrote:

Could you post some code that would help us to reproduce the problem?

On Monday, October 29, 2012 4:33:06 PM UTC-4, William King wrote:

Hello,

I'm having a problem with a native script I'm currently working on. In
the start of the script I use doc().get() to access data and all is well.
However later on I try to access data again in the same manner (after an
if statement) and I get a blank value returned. If I try access these
fields from earlier on in the script all is well.

I was trying to only access certain fields in an if statement to keep
the amount of fields I accessed limited, but it seems that this won't work?

--

Sure, I'm actually calling this from a plugin I'm working on. Here's a gist
of the java code:

On Monday, October 29, 2012 3:22:25 PM UTC-7, Igor Motov wrote:

I am not sure which type of script you are running in your "has_child"
filter. Could you give an example of the query that you are executing?

On Monday, October 29, 2012 6:07:36 PM UTC-4, William King wrote:

It's actually looking like the problem is something else entirely.

The script I'm running is within a "has_child" filter (not query) and it
looks like sometimes the filter is hitting the parent of the children that
I'm querying. So my previous diagnostic was completely off base. I'm
guessing this is the issue as I've been checking the doc.field("_id")
values of each document hit and the ones that are causing issues have
document IDs which correspond to the parent and not the child.

Is this behavior normal?

On Monday, October 29, 2012 2:57:54 PM UTC-7, Igor Motov wrote:

Could you post some code that would help us to reproduce the problem?

On Monday, October 29, 2012 4:33:06 PM UTC-4, William King wrote:

Hello,

I'm having a problem with a native script I'm currently working on. In
the start of the script I use doc().get() to access data and all is well.
However later on I try to access data again in the same manner (after
an if statement) and I get a blank value returned. If I try access these
fields from earlier on in the script all is well.

I was trying to only access certain fields in an if statement to keep
the amount of fields I accessed limited, but it seems that this won't work?

--

Looking at your java code I would say
that TimeframeFilterScriptFactory.NAME should be called for every
timeframe and TimeframeSortScriptFactory.NAME should be called for every
event.

I tried to reproduce the issue based on your description, but everything
seems to be working fine: gist:3977859 · GitHub Could you
modify this script to demonstrate the issue that you are experiencing?

On Monday, October 29, 2012 6:35:27 PM UTC-4, William King wrote:

Sure, I'm actually calling this from a plugin I'm working on. Here's a
gist of the java code:

gist:3976983 · GitHub

On Monday, October 29, 2012 3:22:25 PM UTC-7, Igor Motov wrote:

I am not sure which type of script you are running in your "has_child"
filter. Could you give an example of the query that you are executing?

On Monday, October 29, 2012 6:07:36 PM UTC-4, William King wrote:

It's actually looking like the problem is something else entirely.

The script I'm running is within a "has_child" filter (not query) and it
looks like sometimes the filter is hitting the parent of the children that
I'm querying. So my previous diagnostic was completely off base. I'm
guessing this is the issue as I've been checking the doc.field("_id")
values of each document hit and the ones that are causing issues have
document IDs which correspond to the parent and not the child.

Is this behavior normal?

On Monday, October 29, 2012 2:57:54 PM UTC-7, Igor Motov wrote:

Could you post some code that would help us to reproduce the problem?

On Monday, October 29, 2012 4:33:06 PM UTC-4, William King wrote:

Hello,

I'm having a problem with a native script I'm currently working on. In
the start of the script I use doc().get() to access data and all is well.
However later on I try to access data again in the same manner (after
an if statement) and I get a blank value returned. If I try access these
fields from earlier on in the script all is well.

I was trying to only access certain fields in an if statement to keep
the amount of fields I accessed limited, but it seems that this won't work?

--