'SOLR term frequency

I am using solr, and so far everything is going great. When I do a search, I want to get back how many times the search 'term' was per document, along with the document itself. I have found alot of information but after going trough it I still don't understand how I can do this. Is it that extreme hard ?

Can anyone help me out?

Altough I do get results, the fl field is always 0

http://localhost:8983/solr/collection1/select?q=text:*mySearchTerm*&fl=*,fl:termfreq(text,*mySearchTerm*)


Solution 1:[1]

Ok, I found out that termfreq doesn't work for MultiValues fields. So I used a copy field and added termVectors="true" termPositions="true" termOffsets="true". Now it works

Solution 2:[2]

You might want to check out http://wiki.apache.org/solr/LukeRequestHandler - You should see the tag "numTerms" in the xml returned for you to use based on each field where required too.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nealv
Solution 2 s3rk