You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Andrew Hankinson <an...@rism.digital> on 2022/01/07 10:03:41 UTC

JSON Query API "fields" does not work

Hello,

I am using the JSON Query API, and the 'fields' key does not work as expected.

Using the following query with the `post` tool:

$> echo '{"query":"*:*", "fields": ["id"]}' | ./post -url http://localhost:8983/solr/mycore/select -type application/json -out yes -d

I get the full document back, not just the ID field. If, however, I use:

$> echo '{"query":"*:*", "params": {"fl": ["id"]}}' | ./post -url http://localhost:8983/solr/mycore/select -type application/json -out yes -d

Then the query works as expected.

Can anyone confirm this is an issue? 

If it cannot be reproduced, I can dig deeper into my setup. I am using some default `appends` for `fl` in the request handler for some custom field processing for JSON fields, so it may be an issue with merging the `fields` and the `fl` arrays? Not sure.

Thanks,
-Andrew

Re: JSON Query API "fields" does not work

Posted by Andrew Hankinson <an...@rism.digital>.
No, passing `fields` as a string value does not work. 

I think it's expecting an array, as best I can tell:

https://gitbox.apache.org/repos/asf?p=solr.git;a=blob;f=solr/core/src/java/org/apache/solr/request/json/RequestUtil.java;h=87ba244290d81ee865af9bb464b442f6da787ae8;hb=HEAD#l209

-Andrew

> On 7 Jan 2022, at 12:55, Mikhail Khludnev <mk...@apache.org> wrote:
> 
> Hello, Andrew.
> 
> Could you try to pass a string value for "fields" property? That's what I
> see in TestJsonRequest.
> 
> On Fri, Jan 7, 2022 at 1:03 PM Andrew Hankinson
> <an...@rism.digital> wrote:
> 
>> Hello,
>> 
>> I am using the JSON Query API, and the 'fields' key does not work as
>> expected.
>> 
>> Using the following query with the `post` tool:
>> 
>> $> echo '{"query":"*:*", "fields": ["id"]}' | ./post -url
>> http://localhost:8983/solr/mycore/select -type application/json -out yes
>> -d
>> 
>> I get the full document back, not just the ID field. If, however, I use:
>> 
>> $> echo '{"query":"*:*", "params": {"fl": ["id"]}}' | ./post -url
>> http://localhost:8983/solr/mycore/select -type application/json -out yes
>> -d
>> 
>> Then the query works as expected.
>> 
>> Can anyone confirm this is an issue?
>> 
>> If it cannot be reproduced, I can dig deeper into my setup. I am using
>> some default `appends` for `fl` in the request handler for some custom
>> field processing for JSON fields, so it may be an issue with merging the
>> `fields` and the `fl` arrays? Not sure.
>> 
>> Thanks,
>> -Andrew
> 
> 
> 
> -- 
> Sincerely yours
> Mikhail Khludnev


Re: JSON Query API "fields" does not work

Posted by Andrew Hankinson <an...@rism.digital>.
Sorry, I should have also included my `post` tool command for clarity:

$> echo '{"query":"*:*", "fields": "id,type"}' | ./post -url http://localhost:8983/solr/mycore/select -type application/json -out yes -d

This returns all the fields, not just the `id` and `type` fields. 

I'm on 8.11.1

> On 7 Jan 2022, at 12:55, Mikhail Khludnev <mk...@apache.org> wrote:
> 
> Hello, Andrew.
> 
> Could you try to pass a string value for "fields" property? That's what I
> see in TestJsonRequest.
> 
> On Fri, Jan 7, 2022 at 1:03 PM Andrew Hankinson
> <an...@rism.digital> wrote:
> 
>> Hello,
>> 
>> I am using the JSON Query API, and the 'fields' key does not work as
>> expected.
>> 
>> Using the following query with the `post` tool:
>> 
>> $> echo '{"query":"*:*", "fields": ["id"]}' | ./post -url
>> http://localhost:8983/solr/mycore/select -type application/json -out yes
>> -d
>> 
>> I get the full document back, not just the ID field. If, however, I use:
>> 
>> $> echo '{"query":"*:*", "params": {"fl": ["id"]}}' | ./post -url
>> http://localhost:8983/solr/mycore/select -type application/json -out yes
>> -d
>> 
>> Then the query works as expected.
>> 
>> Can anyone confirm this is an issue?
>> 
>> If it cannot be reproduced, I can dig deeper into my setup. I am using
>> some default `appends` for `fl` in the request handler for some custom
>> field processing for JSON fields, so it may be an issue with merging the
>> `fields` and the `fl` arrays? Not sure.
>> 
>> Thanks,
>> -Andrew
> 
> 
> 
> -- 
> Sincerely yours
> Mikhail Khludnev


Re: JSON Query API "fields" does not work

Posted by Mikhail Khludnev <mk...@apache.org>.
Hello, Andrew.

Could you try to pass a string value for "fields" property? That's what I
see in TestJsonRequest.

On Fri, Jan 7, 2022 at 1:03 PM Andrew Hankinson
<an...@rism.digital> wrote:

> Hello,
>
> I am using the JSON Query API, and the 'fields' key does not work as
> expected.
>
> Using the following query with the `post` tool:
>
> $> echo '{"query":"*:*", "fields": ["id"]}' | ./post -url
> http://localhost:8983/solr/mycore/select -type application/json -out yes
> -d
>
> I get the full document back, not just the ID field. If, however, I use:
>
> $> echo '{"query":"*:*", "params": {"fl": ["id"]}}' | ./post -url
> http://localhost:8983/solr/mycore/select -type application/json -out yes
> -d
>
> Then the query works as expected.
>
> Can anyone confirm this is an issue?
>
> If it cannot be reproduced, I can dig deeper into my setup. I am using
> some default `appends` for `fl` in the request handler for some custom
> field processing for JSON fields, so it may be an issue with merging the
> `fields` and the `fl` arrays? Not sure.
>
> Thanks,
> -Andrew



-- 
Sincerely yours
Mikhail Khludnev