You can use the termfreq or tf function query in your field list to return the term frequency for a term, like:

fl=id,tf(foods,'pizza')

-- Jack Krupansky

-----Original Message----- From: danielitos85
Sent: Wednesday, August 14, 2013 5:29 AM
To: solr-user@lucene.apache.org
Subject: get term frequency, just only keywords search

I need to get the TermFrequency in Solr4 but just about my keywords search
and not for all the keywords that a field cointains.

I try to explain with an example:

I have this fiels:

<field name="id"            type="string"     indexed="true"
stored="true"    required="true" />
<field name="foods"         type="text"       indexed="true"
stored="true"    required="true"        termVectors="true"
termPositions="true"    termOffsets="true"/>

when I try to searh into field "foods" the keyword "pizza" like this:

http://localhost:8983/solr/mycore/select?q=pizza&fl=id&tv=true&df=foods&tv.tf_idf=true&tv.tf=true&tv.df=true&tv.fl=foods&omitHeader=true&defType=dismax

this is my results:

<response>
<result name="response" numFound="1" start="0">
   <doc>
       <str name="id">1</str>
   </doc>
</result>
<lst name="termVectors">
   <str name="uniqueKeyFieldName">id</str>
   <lst name="1">
       <str name="uniqueKey">1</str>
       <lst name="foods">
           <lst name="pizza">
               <int name="tf">5</int>
               <int name="df">3</int>
               <double name="tf-idf">1.6666666666666667</double>
           </lst>
           <lst name="ice-cream">
               <int name="tf">2</int>
               <int name="df">3</int>
               <double name="tf-idf">0.6666666666666666</double>
           </lst>
           <lst name="tomato">
               <int name="tf">2</int>
               <int name="df">1</int>
               <double name="tf-idf">2.0</double>
           </lst>
       </lst>
   </lst>
</lst>

Now, my question is: why I get the tf for all the indexed keywords into
field foods and not only for my keyword search ("pizza")?

Please, have you any suggests? Thanks in advance




--
View this message in context: http://lucene.472066.n3.nabble.com/get-term-frequency-just-only-keywords-search-tp4084510.html Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to