While using highlighting we get output in 2 sections.
<result name="response" numFound="2345" start="0">
<doc>...</doc>
<doc>...</doc>
</result>
<lst name="highlighting">
<lst name="08dcc4e3">...highlighted fields with <em> tag...</lst>
<lst name="12e47c63">...highlighted fields with <em> tag...</lst>
</lst>
Is it possible to have 'em' tags within the fields inside the documents?
For example if query is for 'engine', I should get something like -
<doc>
<str name="content">
Build your own search <em>engine</em> using solr
</str>
.
.
.
</doc>
If the above thing is not possible, is it possible to have highlighting output of document id xyz inside the document with other fields, something like -
<doc>
<str name="id">xyz</str>
.
.
.
<lst name="highlighting">
<arr name="content">
<str>...</str>
</arr>
</lst>
</doc>
If this is not possible with simple config changes and default highlighting, Is it possible with custom highlighting module (by extending default highlighting or so).
I am currently using solr 3.4 but let me know if it is possible in solr versions post 3.4
Related
I am trying to crawl data using Nutch and Index that Data in Solr.
I have follow the steps from this Url Using Nutch with Solr and Nutch Wiki Tutorial
I've successfully Index data using Solrindex command
bin/nutch solrindex http://127.0.0.1:8983/solr/ crawl/crawldb -linkdb crawl/linkdb crawl/segments/* but in Result I can't find the Indexed data.
I want result as below Image
But I can't see any result data at right side.
If you want some data to be returned with the search response, check that the targeted fields are stored by solr, then you can set a list of fields to return in your query using fl param (with stored field name as value). You can also set default fl values in solrconfig.xml.
For example, let's say you want content field to be returned. In your schema.xml, in the <fields> declaration you should have the option stored="true" for this field like so :
<field name="content" type="text" indexed="true" stored="true"/>
Then in solrconfig.xml, declare default fl params in the requestHandler definition, you can set specific fields (space separated field names). The xml sample (grabbed from the tutorial) should look like this if we just want data stored in the content field to be returned.
<requestHandler name="/nutch" class="solr.SearchHandler" >
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<float name="tie">0.01</float>
<str name="qf">
content^0.5 anchor^1.0 title^1.2
</str>
<str name="pf">
content^0.5 anchor^1.5 title^1.2 site^1.5
</str>
<str name="fl">
url content
</str>
<str name="mm">
2<-1 5<-2 6<90%
</str>
<int name="ps">100</int>
<bool hl="true"/>
<str name="q.alt">*:*</str>
<str name="hl.fl">title url content</str>
<str name="f.title.hl.fragsize">0</str>
<str name="f.title.hl.alternateField">title</str>
<str name="f.url.hl.fragsize">0</str>
<str name="f.url.hl.alternateField">url</str>
<str name="f.content.hl.fragmenter">regex</str>
</lst>
</requestHandler>
You can override these defaults right in the query. A common use case is to put "*,score" in the fl area in solr query interface so that you can see all stored fields (using wildcard character *) along with the score in the results. You might also want to specify the query type parameter (qt) according to the targeted request handler (should be "/nutch").
Helpful links :
http://wiki.apache.org/solr/SchemaXml#Common_field_options
http://wiki.apache.org/solr/CommonQueryParameters#fl
I have a multivalued field that I am searching on. In the 'result' area the field is returned as an array of strings. In the highlighting section the array elements are combined into a single string with no delimiter. Do I have to parse the highlighting based on the results section? It seems like highlighting should return an array of strings.
This is what I get back:
<result name="response" numFound="1" start="0">
<doc>
<arr name="NameList">
<str>Beacher, Mike</str>
<str>Cally, Karl T.</str>
<str>Amerson, Judy</str>
</arr>
</doc>
</result>
<lst name="highlighting">
<lst name="my_doc">
<arr name="NameList">
<str>Beacher, MikeCally, Karl T.<em>Amerson, Judy</em>
</str>
</arr>
</lst>
</lst>
I was expecting the highlighting result to look something like this:
<arr name="NameList">
<str>Beacher, Mike</str>
<str>Cally, Karl T.</str>
<str><em>Amerson, Judy</em></str>
</arr>
So far I haven't found any questions about this - unless I am just bad at searching. :)
Solved it.
This functionality is now available using the preserveMulti parameter in Solr 4.1.
Discussed here
I'm using Solr example server to do an investigation. After fed it with all cached documents, mostly html files, it works fine except the highlight part.
The request URL I'm using is as followed,
http://localhost:8983/solr/collection1/select?q=keyword&wt=xml&hl=true
And the XML response is as followed,
<response>
<lst name="responseHeader">...</lst>
<result name="response" numFound="371" start="0">
<doc>
<arr name="links">
<str>rect</str>
<str>FJU_KDJFJJ_DJ_13</str>
</arr>
<str name="id">
F:\SkyDrive\funproj\cache\adfadf\asdff.htm
</str>
<arr name="title">
<str>asdff.htm</str>
</arr>
<arr name="content_type">
<str>text/html; charset=ISO-8859-1</str>
</arr>
<str name="resourcename">
F:\SkyDrive\funproj\cache\adfadf\asdff.htm
</str>
<arr name="content">
<str>...</str>
</arr>
<long name="_version_">1418589758873927680</long>
</doc>
<doc>...</doc>
</result>
<lst name="highlighting">
<lst name="F:\SkyDrive\funproj\cache\adfadf\asdff.htm"/>
<lst name="F:\SkyDrive\funproj\cache\cvzcv\c58053e10vq.htm"/>
<lst name="F:\SkyDrive\funproj\cache\hgdfhdfgh\c00302e10vq.htm"/>
<lst name="F:\SkyDrive\funproj\cache\asdfasdf\c00945e10vq.htm"/>
<lst name="F:\SkyDrive\funproj\cache\hjmyukt\asfdf06113002_03312010.htm"/>
<lst name="F:\SkyDrive\funproj\cache\nmvbmnm\saf0q033111.htm"/>
<lst name="F:\SkyDrive\funproj\cache\lkiullkl\a10-5974_110q.htm"/>
<lst name="F:\SkyDrive\funproj\cache\jhlhjkl\fdfinal.htm"/>
<lst name="F:\SkyDrive\funproj\cache\vcbxcbvcx\zynex10q33110_5132010.htm"/>
<lst name="F:\SkyDrive\funproj\cache\yuiuiou\v185403_10q.htm"/>
</lst>
</response>
The response, no matter JSON or XML, does not have the highlight part at all. I've checked the solrconfig.xml both in local file system and the admin page of the example server. The Highlighting is default on and pre/post are set to ""/"". The example search portal itself works fine with highlight in its results. But since it's not AJAX, there's no way for me to check its result through chrome.
What did I do wrong?
You have to define the fields using hl.fl which needs to be highlighted. For example, if you want to search and highlight hits in content field, you can use query below:
http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content
By default highlighting response returns only one snippet,even if your field have multiple hits. Also the length of snippet(fragsize) is set to 100 chars by default.
You can use hl.snippets and hl.fragsize to modify them.
For example, to modify fragsize:
http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content&hl.fragsize=5000
Passing hl.fragsize=0 will make fragsize unlimited.
For changing number of snippets:
http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content&hl.snippets=10
Refer to solr wiki for more parameters.
you would need to add the field hl.fl on which the highlighting needs to be enabled.
Default value for the param is blank.
I'm indexing rich text documents into SOLR 3.4 using ExtractingRequestHandler and I'm having trouble getting it to behave like I want it to.
I would like to store creation date as a field to use for faceted search later and have defined the following in schema.xml:
<field name="creation_date" type="date" indexed="true" stored="true"/>
I index like this:
curl -s "http://localhost:8983/solr/update/extract?literal.id=myid&resource.name=myfile.xls&commit=true" -F myfile=#/path/to/myfile.xls
I get the dynamic field attr_creation_date (that other rules make sure), but I don't get it as creation_date. I have also unsuccessfully tried to use copyField like so:
<copyField source="attr_creation_date" dest="creation_date"/>
Yet another try was putting this in solrconfig.xml, but no luck:
<str name="fmap.Creation-Date">creation_date</str>
I'm pretty sure I'm missing something basic here. Any help is most appreciated!
Settings for ExtractingRequestHandler in solrconfig.xml:
<requestHandler name="/update/extract" startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
<str name="fmap.content">text</str>
<str name="fmap.Last-Save-Date">last_save_date</str>
<str name="fmap.Creation-Date">creation_date</str>
<str name="fmap.Content-Type">content_type</str>
<str name="lowernames">true</str>
<str name="uprefix">attr_</str>
<str name="captureAttr">true</str>
<str name="fmap.a">links</str>
</lst>
</requestHandler>
My schema.xml file (lots of default stuff): https://gist.github.com/1358002
I am wondering if it is possible with Solr 3.4 to boost a search result, if the query is found in a special field without using the "fieldname:query"-syntax.
Let me explain:
I have several fields in my index. One of it is named "abbreviation" and is filled with text like AVZ, JSP, DECT, ...
To be able to find results when searching purely for "AVZ" I added a
<copyField source="abbreviation" dest="text"/>
in my schema.xml. The field text is my defaultSearchField.
This is not the best solution in my opinion. So I am trying to find out, if it is possible to search for "AVZ" in all fields and if the String is found in the field abbreviation, the result entry should be boosted (increasing the score) so that it will be listed at first entry in the result list. Would be the same as using abbreviation:AVZ AVZ as query.
The other possibility I can think of is to analyze the query. And if a substring like "AVZ" is found, the query will be appended with abbreviation:AVZ. But in this case I must be able to find out, which abbreviations are indexed. Is it possible to retrieve all possible terms of a field from the Solr index using SolrJ?
Best Regards
Tobias
Without the fieldname:term syntax use can define a request handler -
<requestHandler name="search" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="defType">dismax</str>
<str name="qf">
abbreviation^2 text
</str>
<str name="q.alt">*:*</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
</lst>
</requestHandler>
This uses the dismax query parser. You can use edismax as well.
This will boost the results and query would be a simple query as q=AVZ.
If only through url, you can boost match on specific field like mentioned # link
e.g.
q=abbreviation:AVZ^2 text:AVZ
This would boost the results with a match on abbreviation, which would result the documents to appear on top.
It is not possible to get all results with dismax using the *:* query.
However, for all docs just do not pass any q param. q.alt=*:* will return all the docs.
Else, update the defType to edismax.
<requestHandler name="search" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="defType">edismax</str>
<str name="qf">
abbreviation^2 text
</str>
<str name="q.alt">*:*</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
</lst>
</requestHandler>
Apache Solr 6.4.2:
Boosting Exact phrase search not working:
Solrconfig.xml:
explicit
<int name="rows">10</int>
<str name="defType">edismax</str>
<str name="qf">names^50</str>
<!-- <str name="df">text</str> -->
</lst>
Solr query used to test: q=(names:alex%20pandian)&wt=json&debugQuery=on
In debug mode it shows
"parsedquery_toString":"+((names:alex ((names:pandian)^50.0))) ()"
It is boosting the terms from second word only. In this case only Pandian is boosted but Alex is not.