To use SpanFirst you would have to write your own QParserPlugin. Or maybe look into adding support for SpanFirst to the Surround parser https://solr.apache.org/guide/8_9/other-parsers.html#surround-query-parser To test, you may also try the XML QParser https://solr.apache.org/guide/8_9/other-parsers.html#xml-query-parser which as SpanFirst support, but it is not very user friendly.
If I were you I'd instead attempt a custom FieldType borrowing some tricks from https://github.com/cominvent/exactmatch <https://github.com/cominvent/exactmatch>. So you add a special token to the start of every field, i.e. "foo bar" becomes "QQQ foo bar". Then, to boost docs starting with "foo", you issue a phrase query as a boost query bq="QQQ foo"^10 Jan > 25. sep. 2021 kl. 23:41 skrev Thamizh Azhagan <[email protected]>: > > Hi Jan, > > Cam you please help on how to implement SpanFirstQuery in Solr. Is there > any documentation available?? Stuck with implementation. > > On Fri, 24 Sep 2021, 10:53 pm Thamizhazhagan B, <[email protected]> > wrote: > >> Thanks Jan. Will look upon the documentation. >> >> Moreover, the query has starts with (^) operator. The problem is that some >> keywords are working fine with the same query. Some keywords are not. >> >> We observed that some keywords are rendered at top though it presents as >> second word in a title (For.Ex: Test Culture). But we are looking for title >> has keyword as fist word should come at first (For ex: Culture <following >> by other text>. We tried to use 'sow=false". But no luck. >> >> Thanks, >> Thamizh >> >> -----Original Message----- >> From: Jan Høydahl <[email protected]> >> Sent: Saturday, September 25, 2021 12:58 AM >> To: [email protected] >> Subject: Re: Priorities for fields and Phrases while indexing >> >> There is no «starts with» operator. Please read the documentation. You may >> be able to simulate starts with by looking into SpanFirstQuery. Or by >> creating a custom field type, see >> https://urldefense.com/v3/__https://github.com/cominvent/exactmatch__;!!BZ50a36bapWJ!6nuIotIgrsRVm-VwLaF-nvAPgILEyJ1BCek5G5TrC2lFFjlCuDETevc8Yu4Y_YlkYVnt4Q$ >> >> Jan Høydahl >> >>> 24. sep. 2021 kl. 17:08 skrev Thamizhazhagan B < >> [email protected]>: >>> >>> Thanks Jan. We were able to achieve boosting. >>> >>> However, when we are applying boost value for "Starts with" to keyword >>> (For.Example: culture), solr brings the result set wherever the >>> keyword presents but top results are contains the keyword as second >>> word >>> >>> Query: >>> https://urldefense.com/v3/__https://localhost/solr/TestIndex/select?bq >>> =(name_t:*5C*5Eculture)*5E10&bq=(desc_t:*5C*5Eculture)*5E20&q=((((medi >>> acontent_t:culture*AND*categorytype_t:Testdoc)**A-)*OR*((bodycontent_t >>> :(culture)*AND*_templatename:(*22XXX*22))**A-))*AND*haslayout_b:(true) >>> )&defType=edismax&hl.simple.post=**A3C*span*3E*&hl.maxAnalyzedChars=20 >>> 0000&hl.fl=bodycontent_t,mediacontent_t&fl=name_t,desc_title_t,score&r >>> ows=1000__;JSUlJSUlKysrKysrKyslJSsrKysrJS8lKw!!BZ50a36bapWJ!6nuIotIgrs >>> RVm-VwLaF-nvAPgILEyJ1BCek5G5TrC2lFFjlCuDETevc8Yu4Y_Yl6q-zZwg$ >>> >>> Current result: (Data security reasons - mentioned 'xxx' for project >>> specific key words) >> "response":{"numFound":13788,"start":0,"maxScore":130.9114,"docs":[ >>> { >>> "name":"xxx Culture", >>> "score":130.9114}, >>> { >>> "name":"Culture, xxx", >>> "score":130.86884}, >>> { >>> "name":" xxx Culture", >>> "score":130.68527}, >>> { >>> "name":" xxx Culture", >>> "score":130.67133}, >>> { >>> "name":"Culture, xxx ", >>> "score":130.25258}, >>> { >>> "name":"Culture, xxx ", >>> "score":130.20874}, >>> { >>> "name":" xxx Culture", >>> "score":130.17592}, >>> { >>> name":"Culture, xxx", >>> "score":129.13066}, >>> >>> >>> Expected result: wherever 'Culture' as first word should come at first. >> Any help would be highly appreciated. Thanks. >>> >>> >>> -----Original Message----- >>> From: Jan Høydahl <[email protected]> >>> Sent: Wednesday, September 22, 2021 8:45 PM >>> To: [email protected] >>> Subject: Re: Priorities for fields and Phrases while indexing >>> >>> Caution: This email came from outside Kaiser Permanente. Do not open >> attachments or click on links if you do not recognize the sender. >>> >>> ______________________________________________________________________ >>> Please do not cross-post to several lists. This question belongs here in >> the users-list only. >>> >>> You could yse EDismax parser to achieve different boosts per field, >>> see the "qf" parameter in >>> https://urldefense.com/v3/__https://solr.apache.org/guide/8_9/the-exte >>> nded-dismax-query-parser.html__;!!BZ50a36bapWJ!4RDXbrNeBH3xqDT3jtfUsAr >>> 99Z4yB-J7LiYK0-FysA9TWQL7ysveHJz3mj3mU3SXHrVoLA$ >>> >>> If a user types "test phrase", Solr will by default require a pure >> phrase match. >>> You could rewrite that query in your application to something like "test >> phrase" or (test phrase)^0.2 to achieve what you are after. However, users >> may be puzzled that they did not get the phrase they were looking for? >>> >>> Jan >>> >>>> 22. sep. 2021 kl. 14:27 skrev Thamizh Babu <[email protected]>: >>>> >>>> Hi, >>>> >>>> I am new to SOLR. We have a requirement to prioritize fields and >> keyword phrases as below: >>>> >>>> While indexing priority as below >>>> Title - Priority 1 >>>> Short Desc - Priority 2 >>>> Long Desc - Priority 3 >>>> >>>> If user types search phrase like “Test Phrase” >>>> “Test Phrase” – Priority 1 >>>> “Test” – Priority 2 >>>> “Phrase” – Priority 3 >>>> >>>> Please guide us how to give priority while indexing time for above use >> cases. Any help would be highly appreciated. >>>> >>>> Thanks, >>>> Thamizh >>>> >>>> Sent from Mail >>>> <https://urldefense.com/v3/__https://go.microsoft.com/fwlink/?LinkId= >>>> 550986__;!!BZ50a36bapWJ!4RDXbrNeBH3xqDT3jtfUsAr99Z4yB-J7LiYK0-FysA9TW >>>> QL7ysveHJz3mj3mU3TY1MfWjg$ > for Windows >>>> >>>> >>>> < >> https://urldefense.com/v3/__https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient__;!!BZ50a36bapWJ!4RDXbrNeBH3xqDT3jtfUsAr99Z4yB-J7LiYK0-FysA9TWQL7ysveHJz3mj3mU3TWoUnXAA$ >>> Virus-free. >> https://urldefense.com/v3/__http://www.avast.com__;!!BZ50a36bapWJ!4RDXbrNeBH3xqDT3jtfUsAr99Z4yB-J7LiYK0-FysA9TWQL7ysveHJz3mj3mU3R2il159A$ >> < >> https://urldefense.com/v3/__https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient__;!!BZ50a36bapWJ!4RDXbrNeBH3xqDT3jtfUsAr99Z4yB-J7LiYK0-FysA9TWQL7ysveHJz3mj3mU3TWoUnXAA$ >>> >> <x-msg://4/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>--------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] <mailto: >> [email protected]> For additional commands, e-mail: >> [email protected] <mailto:[email protected]> >>> NOTICE TO RECIPIENT: If you are not the intended recipient of this >> e-mail, you are prohibited from sharing, copying, or otherwise using or >> disclosing its contents. If you have received this e-mail in error, please >> notify the sender immediately by reply e-mail and permanently delete this >> e-mail and any attachments without reading, forwarding or saving them. >> v.173.295 Thank you. >>
