You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Hamso <ha...@gmail.com> on 2017/04/11 10:14:34 UTC

Solr/ Velocity dont show full field value

Hey guys,
I have a problem:

In Velocity:

<div>*Beschreibung:*#field('LONG_TEXT')</div>

In Solr the field "LONG_TEXT" dont show everything only the first ~90-110
characters.
But if I set "$doc.getFieldValue('LONG_TEXT')" in the Velocity file, then he
show me everything whats inside in the field "LONG_TEXT".
But there is one problem, if I use "$doc.getFieldValue('LONG_TEXT')" instead
of #field('LONG_TEXT'), the highlight doesnt work.
Can someone please help me, why #field('LONG_TEXT') doesnt show everthing
whats inside the field, or why highlighting with
"$doc.getFieldValue('LONG_TEXT')" doesnt work.

Schema.xml:

      <field name="LONG_TEXT" type="text_ngram" indexed="true" stored="true"
/>

    <fieldType name="text_ngram" class="solr.TextField"
positionIncrementGap="100">
    <analyzer type="index">
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.StopFilterFactory" words="stopwords.txt"
ignoreCase="true"/>
      <filter class="solr.LowerCaseFilterFactory" />
      <filter class="solr.NGramFilterFactory" minGramSize="2"
maxGramSize="500"/>
     </analyzer>
    <analyzer type="query">
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.StopFilterFactory" words="stopwords.txt"
ignoreCase="true"/>
      <filter class="solr.SynonymFilterFactory" expand="true"
ignoreCase="true" synonyms="synonyms.txt"/>
      <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
</fieldType>

solrconfig only in /browse:

       <str name="hl">on</str>
       <str name="hl.fl">LONG_TEXT</str>
       <str name="hl.preserveMulti">true</str>
       <str name="hl.encoder">html</str>
       <str name="hl.simple.pre">&lt;b&gt;</str>
       <str name="hl.simple.post">&lt;/b&gt;</str>





--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Velocity-dont-show-full-field-value-tp4329290.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr/ Velocity dont show full field value

Posted by Erik Hatcher <er...@gmail.com>.
#field() is defined in _macros.vm as this monstrosity:

# TODO: make this parameterized fully, no context sensitivity
#macro(field $f)
  #if($response.response.highlighting.get($docId).get($f).get(0))
    #set($pad = "")
      #foreach($v in $response.response.highlighting.get($docId).get($f))
        $pad$v##  #TODO: $esc.html() or maybe make that optional?
        #set($pad = " ... ")
      #end
  #else
    $esc.html($display.list($doc.getFieldValues($f), ", "))
  #end
#end
Basically that’s saying if there is highlighting returned for the specified field, then render it, otherwise render the full field value.  $doc.getFieldValue() won’t ever work with highlighting - it’s the raw returned field value (or empty, potentially) - highlighting has to be looked up separately and that’s what the #field() macro tries to do - make it look a bit more seamless and slick, to just do #field(“field_name”).  But it does rely on highlighting working - so try the json or xml response until you get the highlighting configured as needed.

	Erik


> On Apr 11, 2017, at 6:14 AM, Hamso <ha...@gmail.com> wrote:
> 
> Hey guys,
> I have a problem:
> 
> In Velocity:
> 
> <div>*Beschreibung:*#field('LONG_TEXT')</div>
> 
> In Solr the field "LONG_TEXT" dont show everything only the first ~90-110
> characters.
> But if I set "$doc.getFieldValue('LONG_TEXT')" in the Velocity file, then he
> show me everything whats inside in the field "LONG_TEXT".
> But there is one problem, if I use "$doc.getFieldValue('LONG_TEXT')" instead
> of #field('LONG_TEXT'), the highlight doesnt work.
> Can someone please help me, why #field('LONG_TEXT') doesnt show everthing
> whats inside the field, or why highlighting with
> "$doc.getFieldValue('LONG_TEXT')" doesnt work.
> 
> Schema.xml:
> 
>      <field name="LONG_TEXT" type="text_ngram" indexed="true" stored="true"
> />
> 
>    <fieldType name="text_ngram" class="solr.TextField"
> positionIncrementGap="100">
>    <analyzer type="index">
>      <tokenizer class="solr.StandardTokenizerFactory"/>
>      <filter class="solr.StopFilterFactory" words="stopwords.txt"
> ignoreCase="true"/>
>      <filter class="solr.LowerCaseFilterFactory" />
>      <filter class="solr.NGramFilterFactory" minGramSize="2"
> maxGramSize="500"/>
>     </analyzer>
>    <analyzer type="query">
>      <tokenizer class="solr.StandardTokenizerFactory"/>
>      <filter class="solr.StopFilterFactory" words="stopwords.txt"
> ignoreCase="true"/>
>      <filter class="solr.SynonymFilterFactory" expand="true"
> ignoreCase="true" synonyms="synonyms.txt"/>
>      <filter class="solr.LowerCaseFilterFactory" />
>    </analyzer>
> </fieldType>
> 
> solrconfig only in /browse:
> 
>       <str name="hl">on</str>
>       <str name="hl.fl">LONG_TEXT</str>
>       <str name="hl.preserveMulti">true</str>
>       <str name="hl.encoder">html</str>
>       <str name="hl.simple.pre">&lt;b&gt;</str>
>       <str name="hl.simple.post">&lt;/b&gt;</str>
> 
> 
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-Velocity-dont-show-full-field-value-tp4329290.html
> Sent from the Solr - User mailing list archive at Nabble.com.