Solr/SolrJ: How do you Highlight non-text fields?

Highlighting is not possible on non "text" fields. Look at this.

Up vote 0 down vote favorite share g+ share fb share tw.

I cannot find a example on the web for non-text fields. Is it even possible? Specifically I want to highlight the Date value in the document that meets the query.

I am using solrJ to peform the query, could it be the limiting factor? Solr solrj link|improve this question asked Jul 14 '11 at 7:15Moogie31.

Highlighting is not possible on non "text" fields. Look at this: /** * Returns a collection of the names of all stored fields which can be * highlighted the index reader knows about. */ public Collection getStoredHighlightFieldNames() { if (storedHighlightFieldNames == null) { storedHighlightFieldNames = new LinkedList(); for (String fieldName : fieldNames) { try { SchemaField field = schema.

GetField(fieldName); Especially here: if (field.stored() && ((field.getType() instanceof org.apache.solr.schema. TextField) || (field.getType() instanceof org.apache.solr.schema. StrField))) { until here storedHighlightFieldNames.

Add(fieldName); } } catch (RuntimeException e) { // getField() throws a SolrException, but it arrives as a RuntimeException log. Warn("Field \"" + fieldName + "\" found in index, but not defined in schema. "); } } } return storedHighlightFieldNames; }.

Thanks! Although it is as I feared :( – Moogie Jul 14 '11 at 23:08 How would one then identify which non-text fields caused the document to meet the query? – Moogie Jul 14 '11 at 23:08 You mean probably which non-text fields matched a part of the query.

Afaik there is no implementation for returning direct matches. – fyr Jul 15 '11 at 5:22 Thanks for the response, I am not sure that we are talking about the same thing however... – Moogie Jul 15 '11 at 6:02 Thanks for the response, I am not sure that we are talking about the same thing however... Say I have a document that has two text fields A="aaaaa" and B="sssss" and one date field D=20100101. A user initaited query is requested( A:blah AND D:20100101 ).

It returns the document, but I do not know what field in the document met the query (i.e. The date) as there is no highlighting for the date. – Moogie Jul 15 '11 at 6:08.

You can't do this as was explained. But it's super simple to adapt Solr to handle this. Create another field for your date but in string format.

Now just use a copyField: Then just add the field date1_str to your query.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions