JSON Request API and request handlers defaults
Hello! I am seeing a disconnect between the Solr JSON Request API and the `defaults` section in the request handlers, specifically around the handling of 'fields' and 'fl' parameters. To demonstrate, I have a request handler that looks like this: all 20 field1 field2 field3 I then send a JSON Request API request that overrides it, but uses the 'fields' key in a JSON Request. { "query": "foo", "fields": ["field4", "field5", "field6"] } What I would expect is to see the returned documents with fields 4, 5, and 6 present, but instead they are returned with fields 1, 2, and 3 (the defaults). I can work around this issue by using the 'params' key in the request: { "query": "foo", "params": {"fl": ["field4", "field5", "field6"]} } In this case I see fields 4, 5, and 6 in the result, but this means that I cannot use the "fields" parameter in the JSON Request API. I have also tried changing the request handler to: field1 field2 field3 but this does not work. Is this a known bug? Many thanks, -Andrew Hankinson
Re: Random Field - # digits
You could use the UUIDUpdateProcessorFactory to automatically add a UUID to each document and use that as the tie-breaker field. https://solr.apache.org/guide/8_1/update-request-processors.html#uuidupdateprocessorfactory The chances of collision of UUIDs is well-known, and highly unlikely. https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions > On 31 Aug 2021, at 14:04, rgamarra wrote: > > hi, > >> Random ≠ unique. > > Agree. They are not the same. I don't want a tie breaker, I want to know > how many ties I would face. > > The implementation where it's being used has some other (posterior) sorting > criteria. So the question can be rephrased as whether posterior orders have > any effect or not. > > For example, given > > sort= random_1234 DESC, price DESC > > At the end of the day, does the "price DESC" have any effect (which > translates to how often ties in the random do happen)? > > I took a glimpse at > https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/schema/RandomSortField.java > and I conclude that > - an int is being used. > - it's a hashing of the #doc + see, more than a random number generator of > a certain distribution. > > Best. Thanks. > > > -- > Rodolfo Federico Gamarra > > > On Tue, Aug 31, 2021 at 3:00 AM Thomas Corthals > wrote: > >> Hi Rodolfo >> >> Random ≠ unique. If you really need a tie breaker, you'll have to sort on >> the uiqueKey field. >> >> What is your use case here? When using a cursor, sorting on a random field >> will yield confusing results. >> >> Thomas >> >> Op ma 30 aug. 2021 om 17:33 schreef rgamarra : >> >>> Hi there! I'm using random fields (eg sort=random_1234 DESC) as a tie >>> breaker. >>> >>> I'm wondering the underlying random sequence how many digits uses for >> each >>> generated number. >>> >>> My result sets my contain (in principle) millions of results, so I would >>> like to have an estimation of possible clashes (ie two results ending >> with >>> the same random under, and then being a tie in the result set). >>> >>> Best regards. >>> >>> -- >>> Rodolfo Federico Gamarra >>> >>
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
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 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 > 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
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 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 > 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: Customize sort-behaviour on solr.StrField for German language
You can use the ICU Collation Field instead of string: This sorts numbers and letters correctly, as well as does Unicode folding, so 1,2,3...10...20, instead of 1,10...2,20...,3, and folds the characters so that ä,á, etc. are sorted as "a". https://solr.apache.org/guide/8_11/language-analysis.html#unicode-collation > On 1 Feb 2022, at 14:36, Markus Jelsma wrote: > > Hello Sebastian, > > This the natural sort order, just look at an ASCII-table. If you want > charachters nicely bundled together you can either make a complicated > Comparator or CopyField the original string value to a analyzed Text field > that has a KeywordTokenizer, and an ASCIIFoldingFilter configured. > > Sort on that field, and do a secondary sort on the original field to take > care of the cases. > > Regards, > Markus > > Op di 1 feb. 2022 om 13:07 schreef Sebastian Riemer : > >> I am using Solr 8.10 >> >> >> LITTERA Software & Consulting GmbH >> >> A-6060 Hall i.T., Haller Au 19a >> Telefon: +43 (0) 50 765 000, Fax: +43 (0) 50 765 118 >> Sitz: Hall in Tirol, eingetragen beim Handelsgericht Innsbruck, >> Firmenbuch-Nr. FN 295807k, geschäftsführender Gesellschafter: Albert >> Unterkircher, MSc >> >> D-80687 München, Landsberger Straße 155 >> Telefon: +49 (0) 89 919 29 122, Fax: +49 (0) 89 919 29 123 >> Sitz: München, eingetragen beim Amtsgericht München >> unter HRB 103698, Geschäftsführer: Albert Unterkircher >> E-Mail: s.rie...@littera.eu >> Homepage:www.littera.eu >> >> Diese Nachricht kann vertrauliche, nicht für die Veröffentlichung >> bestimmte und/oder rechtlich geschützte Informationen enthalten. Falls Sie >> nicht der beabsichtigte Empfänger sind, beachten Sie bitte, dass jegliche >> Veröffentlichung, Verbreitung oder Vervielfältigung dieser Nachricht >> strengstens untersagt ist. Sollten Sie diese Nachricht irrtümlich erhalten >> haben, informieren Sie bitte sofort den Absender durch Anruf oder >> Rücksendung der Nachricht und vernichten Sie diese. >> >> This communication may contain information that is legally privileged, >> confidential or exempt from disclosure. If you are not the intended >> recipient, please note that any dissemination, distribution or copying of >> this communication is strictly prohibited. Anyone who receives this >> message in error should notify the sender immediately by telephone or by >> return e-mail and delete this communication entirely from his or her >> computer. >> >> -Ursprüngliche Nachricht- >> Von: Sebastian Riemer >> Gesendet: Dienstag, 1. Februar 2022 12:58 >> An: solr-u...@lucene.apache.org >> Betreff: Customize sort-behaviour on solr.StrField for German language >> >> Hello, >> >> I have documents with family names in german language context. >> The field type is defined like this: > class="solr.StrField" sortMissingLast="true" /> >> >> When sorting by this family name, I get results ordered like that: >> >> Ascending order: >> 1. Bart >> 2. Otz >> 3. Ozzbourne >> 4. Zacharias >> 5. bariton >> 6. biene >> 7. burtsch >> 8. ozza >> 9. Ádele >> 10. Òle >> 11. Ônna >> 12. Ötz >> 13. ägnie >> 14. órthega >> >> So, the ordering is: >> >> 1. A-Z (Uppercase) >> 2. a-z (Lowercase) >> 3. Umlauts and special accents >> >> That ordering seems suprising to me, I'd prefer it like this: >> >> 1. aäàâ-z (Lowercase) >> 2. AÄÀÂ-Z (Uppercase) >> >> Or in other words, lowercase before uppercase, and Umlauts and Special >> accents after its "natural character". >> >> Here is the full query fort he above example: >> >> start=0 >> &rows=50 >> &fq=tenant_id:1 >> &fq=u_markedAsDeleted_b:false >> >> &fq={!tag%3Du_cg_customergroup_0}(((u_customerGroupMemberships_customergroup_cp_ts_ns:(24 >> &fq=u_id_cp_s:[*+TO+*]&q=*:* >> &facet=true >> &facet.missing=true >> &facet.sort=count >> &facet.mincount=1 >> &sort=u_familyName_cp_s+asc,u_userName_cp_s+desc >> >> &qf=u_userName_cp_s^20+u_displayName_cp_s^20++text^2+text_en+text_de+text_it >> &pf=u_userName_cp_s^100+u_displayName_cp_s^20++text^10 >> &mm=100%25 >> >> >> Could you please give me some direction which parts of the documentation I >> can study to learn about sorting and how to achieve a custom sorting? >> >> Thank you and best regards, >> >> Sebastian >> >>
Re: Is there a way to sort alphanumerically?
I use this field definition for a sort field: This seems to work well. -Andrew > On 10 Nov 2022, at 11:06, Netta Steinberg wrote: > > Hi all, > > I want to sort value alphabetically, but also numerically. > Example: > I want that the following items > A1 > B4 > A2 > A19 > B10 > > Will be sorted in the following order > A1 > A2 > A19 > B2 > B19 > > So values that start with A will appear before values that start with B, but > also A2 will appear before A19, because the numerical value of 19 is greater > then the numerical value of 2. > I've seen similar questions in StackOverflow, but the suggestions were to pad > the values with zeros (so, e.g. A2 will become A02) but this is not an option. > All > > Thanks, > Netta >
JSON formatting in 9.3.0 query UI
Hi everyone, I've looked through the Jira boards but I couldn't see any mention of this as an issue. Since upgrading to Solr 9.3.0, my JSON query results in the built-in query UI seem to be lacking indents, so that everything is left-aligned. I've tried different browsers, and have cleared caches but with the same results. Is anyone else seeing this? Thanks, -Andrew
Invalid JSON response with UUID field
Hi, I have a schema with a UUID field type configured as a unique key. I recently upgraded my Solr installation to 9.3 (from 7.6) and my application stopped working. It turns out that Solr has stopped encoding UUIDs as strings in the JSON response writer. Whereas before I would get: "id":"76af09e3-db43-4e7e-a46f-9bf03e343db9", Now I get: "id":1b5230fb-a15d-4aea-8720-8e0a1c6e47ae, Of course, UUIDs are not a valid JSON data type, so this looks like a bug to me? -Andrew
Re: Invalid JSON response with UUID field
No SolrCloud, complete wipe and reindex of the data, select handler. > On 1 Dec 2023, at 07:54, Mikhail Khludnev wrote: > > It might have the same root cause like > https://issues.apache.org/jira/browse/SOLR-10653?filter=-3 Could you share > more details about your env setup: is it "SolrCloud"? is it /get or /select > ? etc. > >> On Fri, Dec 1, 2023 at 12:05 AM Andrew Hankinson >> wrote: >> >> Hi, >> >> I have a schema with a UUID field type configured as a unique key. >> >> > multiValued="false" /> >> >> I recently upgraded my Solr installation to 9.3 (from 7.6) and my >> application stopped working. It turns out that Solr has stopped encoding >> UUIDs as strings in the JSON response writer. >> >> Whereas before I would get: >> >> "id":"76af09e3-db43-4e7e-a46f-9bf03e343db9", >> >> Now I get: >> >> "id":1b5230fb-a15d-4aea-8720-8e0a1c6e47ae, >> >> Of course, UUIDs are not a valid JSON data type, so this looks like a bug >> to me? >> >> -Andrew > > > > -- > Sincerely yours > Mikhail Khludnev
Error message in multiThreaded=true
Hi everyone, I just installed 9.7.0 and thought I would try the new multiThreaded search. When I do, running my 'normal' queries but with the `multiThreaded=true` parameter set, this error appears in the logs: 2024-09-10 16:19:45.060 ERROR (qtp1756573246-62-null-37) [c: s: r: x:core-name t:null-37] o.a.s.s.MultiThreadedSearcher raw read max=5922019 I tracked this down to this line: https://github.com/apache/solr/blob/5bc7c1618e05b35bd0fa8471ae09329357a82036/solr/core/src/java/org/apache/solr/search/MultiThreadedSearcher.java#L88 I'm not really sure what to do to fix this error. It may only appear when I haven't set any filter on the results? Is this really an error, or should it be a warning or even an info? It seems like if 'needDocSet' is false, it will raise the error, but will then create a new DocSetCM object? Thanks,' -Andrew
Re: Problem with POST in python code
You're not actually POSTing the data. The requests module is a lot easier than using the urllib module. https://requests.readthedocs.io/en/latest/ r = requests.post('http://localhost:8983/solr/films/query', data={"query":"*:*"}) print(r.json()) This should set all the appropriate headers as well. -Andrew > On 17 Dec 2024, at 10:53, Macfarlane, Andrew > wrote: > > Hi > > I’m trying to connect with a SOLR server, using the POST methods in python, > but I’m getting an error. > > This is the code (full file is attached): > > #Form the URL > searchURL = 'http://localhost:8983/solr/films/query' > > querytext = {"json":{"query":"shane"}} > #querytext = {"query":"*:*"} > > #form the query > query = urllib.parse.urlencode(querytext).encode('utf-8') > > #get data from the server > try: > connection = urllib.request.Request(searchURL, query) > except Exception as error: > print("Connection failed: ", error) > exit() > > connection.add_header('Content-Type', 'application/json') > > #extract data from the connection made > try: > response = urllib.request.urlopen(connection) > except Exception as error: > print("No response returned: ", error) > exit() > > Reponse is: > > solr-9.6.1>python python-apps\film-POST.py > No response returned: HTTP Error 400: Bad Request > > Logging on the server gives: > > > I’ve attempted many ways resolving this to address the issue, but with no > success. Can someone help me please? > > Cheers > Andy > > --
Re: Logging POST parameters
I think it only looks at the GET parameters, though. With the JSON Request API, the parameters are sent in the body of the request, and I can't see any code in the links that you sent that looks at the body of the request for the search parameters. > On 23 Jun 2025, at 10:14, Mikhail Khludnev wrote: > > Hi, > It seems like it works by design. see > https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/core/SolrCore.java#L2932 > It logs only query string params if logParamsList is absent, and > perhaps you'll get all json request logged if set logParamsList=json see > https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java#L182 > but I'm not sure whether it works as you need. > > On Mon, Jun 23, 2025 at 10:07 AM Andrew Hankinson > wrote: > >> Hello, >> >> I am on Solr 9.8.1 in standalone mode, and I'm trying to debug a number of >> slow queries. >> >> We've implemented almost all of our searches using the JSON Request API, >> https://solr.apache.org/guide/solr/latest/query-guide/json-request-api.html >> >> However, in the logs, and in the slow query logs, the JSON Request API >> search parameters do not appear: >> >> 2025-06-23 06:40:36.284 WARN (qtp1844334363-624-null-177821) [c: s: r: >> x:core_name t:null-177821] o.a.s.c.S.SlowRequest slow: webapp=/solr >> path=/select params={} hits=0 status=0 QTime=16914 >> >> You can imagine this makes it difficult to tell what is causing the >> problem! >> >> I've looked around and couldn't really find anything. I'm hesitant to use >> the "logParamsList" query parameter since I would have to 'opt-in' to quite >> a big list of query parameters. I've also tried enabling the "temporary" >> logging, but I think there's a bug with enabling these in standalone mode? >> I get an error "Parameter nodes only supported in Cloud mode". >> >> Is there a secret incantation that would help here? >> >> Thanks, >> -Andrew > > > > -- > Sincerely yours > Mikhail Khludnev
Logging POST parameters
Hello, I am on Solr 9.8.1 in standalone mode, and I'm trying to debug a number of slow queries. We've implemented almost all of our searches using the JSON Request API, https://solr.apache.org/guide/solr/latest/query-guide/json-request-api.html However, in the logs, and in the slow query logs, the JSON Request API search parameters do not appear: 2025-06-23 06:40:36.284 WARN (qtp1844334363-624-null-177821) [c: s: r: x:core_name t:null-177821] o.a.s.c.S.SlowRequest slow: webapp=/solr path=/select params={} hits=0 status=0 QTime=16914 You can imagine this makes it difficult to tell what is causing the problem! I've looked around and couldn't really find anything. I'm hesitant to use the "logParamsList" query parameter since I would have to 'opt-in' to quite a big list of query parameters. I've also tried enabling the "temporary" logging, but I think there's a bug with enabling these in standalone mode? I get an error "Parameter nodes only supported in Cloud mode". Is there a secret incantation that would help here? Thanks, -Andrew
Re: Logging POST parameters
Sorry -- I also meant to mention that I set `logParamsList=json` but that didn't work because I think it's looking for a "&json=... GET parameter. > On 23 Jun 2025, at 10:14, Mikhail Khludnev wrote: > > Hi, > It seems like it works by design. see > https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/core/SolrCore.java#L2932 > It logs only query string params if logParamsList is absent, and > perhaps you'll get all json request logged if set logParamsList=json see > https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java#L182 > but I'm not sure whether it works as you need. > > On Mon, Jun 23, 2025 at 10:07 AM Andrew Hankinson > wrote: > >> Hello, >> >> I am on Solr 9.8.1 in standalone mode, and I'm trying to debug a number of >> slow queries. >> >> We've implemented almost all of our searches using the JSON Request API, >> https://solr.apache.org/guide/solr/latest/query-guide/json-request-api.html >> >> However, in the logs, and in the slow query logs, the JSON Request API >> search parameters do not appear: >> >> 2025-06-23 06:40:36.284 WARN (qtp1844334363-624-null-177821) [c: s: r: >> x:core_name t:null-177821] o.a.s.c.S.SlowRequest slow: webapp=/solr >> path=/select params={} hits=0 status=0 QTime=16914 >> >> You can imagine this makes it difficult to tell what is causing the >> problem! >> >> I've looked around and couldn't really find anything. I'm hesitant to use >> the "logParamsList" query parameter since I would have to 'opt-in' to quite >> a big list of query parameters. I've also tried enabling the "temporary" >> logging, but I think there's a bug with enabling these in standalone mode? >> I get an error "Parameter nodes only supported in Cloud mode". >> >> Is there a secret incantation that would help here? >> >> Thanks, >> -Andrew > > > > -- > Sincerely yours > Mikhail Khludnev
Re: Logging POST parameters
My Java knowledge is limited to read-only, but could you tell me more about what you mean by "a contribution for common cases is welcomed!"? I'm happy to write docs or a use case or a JIRA ticket if that is worthwhile? > On 23 Jun 2025, at 12:41, Mikhail Khludnev wrote: > > Turns out that params are loaded into req.toLog here [1] that's happened > before stream body is parsed and json is inserted as json param at [2] > As a quick custom fix you may develop a component which will put > req.params.json into req.toLog. > > Also, a contribution for common cases is welcomed! > > [1] > https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/core/SolrCore.java#L2916 > [2] > https://github.com/apache/solr/blob/b76a29d17c874806e3b6516810772e2238e93098/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java#L235 > > On Mon, Jun 23, 2025 at 11:32 AM Andrew Hankinson > wrote: > >> Sorry -- I also meant to mention that I set `logParamsList=json` but that >> didn't work because I think it's looking for a "&json=... GET parameter. >> >>> On 23 Jun 2025, at 10:14, Mikhail Khludnev wrote: >>> >>> Hi, >>> It seems like it works by design. see >>> >> https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/core/SolrCore.java#L2932 >>> It logs only query string params if logParamsList is absent, and >>> perhaps you'll get all json request logged if set logParamsList=json see >>> >> https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java#L182 >>> but I'm not sure whether it works as you need. >>> >>> On Mon, Jun 23, 2025 at 10:07 AM Andrew Hankinson >>> wrote: >>> >>>> Hello, >>>> >>>> I am on Solr 9.8.1 in standalone mode, and I'm trying to debug a number >> of >>>> slow queries. >>>> >>>> We've implemented almost all of our searches using the JSON Request API, >>>> >> https://solr.apache.org/guide/solr/latest/query-guide/json-request-api.html >>>> >>>> However, in the logs, and in the slow query logs, the JSON Request API >>>> search parameters do not appear: >>>> >>>> 2025-06-23 06:40:36.284 WARN (qtp1844334363-624-null-177821) [c: s: r: >>>> x:core_name t:null-177821] o.a.s.c.S.SlowRequest slow: webapp=/solr >>>> path=/select params={} hits=0 status=0 QTime=16914 >>>> >>>> You can imagine this makes it difficult to tell what is causing the >>>> problem! >>>> >>>> I've looked around and couldn't really find anything. I'm hesitant to >> use >>>> the "logParamsList" query parameter since I would have to 'opt-in' to >> quite >>>> a big list of query parameters. I've also tried enabling the "temporary" >>>> logging, but I think there's a bug with enabling these in standalone >> mode? >>>> I get an error "Parameter nodes only supported in Cloud mode". >>>> >>>> Is there a secret incantation that would help here? >>>> >>>> Thanks, >>>> -Andrew >>> >>> >>> >>> -- >>> Sincerely yours >>> Mikhail Khludnev >> >> > > -- > Sincerely yours > Mikhail Khludnev
Re: Logging POST parameters
Done, thank you. https://issues.apache.org/jira/browse/SOLR-17794 -Andrew > On 23 Jun 2025, at 14:42, Mikhail Khludnev wrote: > > In that phrase I invited you to contribute the code, which fits in the > generic usecase. But, ok you can start with a JIRA ticket, it seems like > the lack of functionality. > Meanwhile, the particular case might be fixed quickly (and dirty) with a > custom few-lines component. > > On Mon, Jun 23, 2025 at 2:24 PM Andrew Hankinson > wrote: > >> My Java knowledge is limited to read-only, but could you tell me more >> about what you mean by "a contribution for common cases is welcomed!"? >> >> I'm happy to write docs or a use case or a JIRA ticket if that is >> worthwhile? >> >>> On 23 Jun 2025, at 12:41, Mikhail Khludnev wrote: >>> >>> Turns out that params are loaded into req.toLog here [1] that's happened >>> before stream body is parsed and json is inserted as json param at [2] >>> As a quick custom fix you may develop a component which will put >>> req.params.json into req.toLog. >>> >>> Also, a contribution for common cases is welcomed! >>> >>> [1] >>> >> https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/core/SolrCore.java#L2916 >>> [2] >>> >> https://github.com/apache/solr/blob/b76a29d17c874806e3b6516810772e2238e93098/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java#L235 >>> >>> On Mon, Jun 23, 2025 at 11:32 AM Andrew Hankinson >>> wrote: >>> >>>> Sorry -- I also meant to mention that I set `logParamsList=json` but >> that >>>> didn't work because I think it's looking for a "&json=... GET parameter. >>>> >>>>> On 23 Jun 2025, at 10:14, Mikhail Khludnev wrote: >>>>> >>>>> Hi, >>>>> It seems like it works by design. see >>>>> >>>> >> https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/core/SolrCore.java#L2932 >>>>> It logs only query string params if logParamsList is absent, and >>>>> perhaps you'll get all json request logged if set logParamsList=json >> see >>>>> >>>> >> https://github.com/apache/solr/blob/e17078a98a8ebea1a28853d02527f4dc81da4d6b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java#L182 >>>>> but I'm not sure whether it works as you need. >>>>> >>>>> On Mon, Jun 23, 2025 at 10:07 AM Andrew Hankinson >>>>> wrote: >>>>> >>>>>> Hello, >>>>>> >>>>>> I am on Solr 9.8.1 in standalone mode, and I'm trying to debug a >> number >>>> of >>>>>> slow queries. >>>>>> >>>>>> We've implemented almost all of our searches using the JSON Request >> API, >>>>>> >>>> >> https://solr.apache.org/guide/solr/latest/query-guide/json-request-api.html >>>>>> >>>>>> However, in the logs, and in the slow query logs, the JSON Request API >>>>>> search parameters do not appear: >>>>>> >>>>>> 2025-06-23 06:40:36.284 WARN (qtp1844334363-624-null-177821) [c: s: >> r: >>>>>> x:core_name t:null-177821] o.a.s.c.S.SlowRequest slow: webapp=/solr >>>>>> path=/select params={} hits=0 status=0 QTime=16914 >>>>>> >>>>>> You can imagine this makes it difficult to tell what is causing the >>>>>> problem! >>>>>> >>>>>> I've looked around and couldn't really find anything. I'm hesitant to >>>> use >>>>>> the "logParamsList" query parameter since I would have to 'opt-in' to >>>> quite >>>>>> a big list of query parameters. I've also tried enabling the >> "temporary" >>>>>> logging, but I think there's a bug with enabling these in standalone >>>> mode? >>>>>> I get an error "Parameter nodes only supported in Cloud mode". >>>>>> >>>>>> Is there a secret incantation that would help here? >>>>>> >>>>>> Thanks, >>>>>> -Andrew >>>>> >>>>> >>>>> >>>>> -- >>>>> Sincerely yours >>>>> Mikhail Khludnev >>>> >>>> >>> >>> -- >>> Sincerely yours >>> Mikhail Khludnev >> >> > > -- > Sincerely yours > Mikhail Khludnev