SOLR term frequency

2020-04-27 03:15发布

问题:

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*)

回答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



回答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.