Welcome to the Mythicsoft Q&A site for:

- Agent Ransack
- FileLocator Lite
- FileLocator Pro

Please feel free to ask any questions on these products or even answer other community member questions.

Useful Links:

- Contact Us
- Help Manuals
- Mythicsoft Home
0 votes

I was trying to figure out how to export the contents of the HIT tab in the search results as part of the export?

For example if a I construct a boolean OR query and a file is located, I'd like to know what criteria it met.

This information is displayed in the Hits tab when I click on a file but i cant export that information as part of the export.

Thanks!

by (20 points)

What type of export are you looking at? You can export in HTML and it'll produce a highlighted output very similar to the Hits tab.

I'm looking for a hybrid out of the output from here:
//qa.mythicsoft.com/index.php/10025/how-do-i-see-if-a-list-of-keywords-exists-in-a-list-of-files

and the output from the full output. I'd like to be able to display what part of the query yielded the hit. It'd make it easier to generate a CSV/Tab delimited file and sort it by 'hits'. A sample would be:

keyword hit, file details, file properties

Then I'd be able to sort the sheet and show all the hits by keyword.

So would you want the format something like:

File name, path, size, modified date, hit count, line numer, line text, hit-text1, hit-text2 etc..

That's exactly right. The goal is to be able to determine why the file was a hit. Lets say I construct a really long query with several boolean conditions. I'd like to be able to discern why the file is on the list by seeing the condition that it met.

1 Answer

0 votes

You could do this with Custom XSLT formatting. If you just want file name with hits then try this transform:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
			xmlns:rslt="http://www.mythicsoft.com/FileLocator_16Aug2005"
           version="1.0">

  <xsl:output method="text" indent="yes"/>
  <xsl:key name="hits-value" match="rslt:hit" use="concat(../../../rslt:path, ../../../rslt:name, substring(../rslt:text, @rslt:exprstart + 1, @rslt:exprlength))" />

  <xsl:template match="/">
    <xsl:apply-templates select="//rslt:file"/>
		<xsl:text>&#09;</xsl:text>	<!-- Tab separator -->
  </xsl:template>

  <xsl:template match="rslt:file">
    <xsl:value-of select="rslt:path"/>
	<xsl:text>&#09;</xsl:text>	<!-- Tab separator -->
    <xsl:value-of select="rslt:name"/>
	<xsl:text>&#09;</xsl:text>	<!-- Tab separator -->
    <xsl:value-of select="rslt:size"/>
	<xsl:text>&#09;</xsl:text>	<!-- Tab separator -->
    <xsl:value-of select="rslt:modified"/>
	<xsl:text>&#09;</xsl:text>	<!-- Tab separator -->
    <xsl:value-of select="rslt:contents/@rslt:totalhitcount"/>
    <xsl:apply-templates select="rslt:contents/rslt:line/rslt:hit"/>
    <xsl:text>&#13;&#10;</xsl:text>   <!-- CR LF end of line -->
  </xsl:template>
  
  <xsl:template match="rslt:hit">
  	<xsl:if test="generate-id() = generate-id(key('hits-value', concat(../../../rslt:path, ../../../rslt:name, substring(../rslt:text, @rslt:exprstart + 1, @rslt:exprlength)) ))">      
		<xsl:text>&#09;</xsl:text>	<!-- Tab separator -->
		
    	<xsl:value-of select="substring(../rslt:text, @rslt:exprstart + 1, @rslt:exprlength)"/>
    </xsl:if>
  </xsl:template>
  

</xsl:stylesheet>

Step-by-step:

  1. Save the above transform to a file, e.g. filename_with_hits.xsl
  2. Click the File->Export Results... menu option
  3. Specify the filename_with_hits.xsl file in the Custom (XSLT) field
  4. Choose File name AND Contents for exporting
  5. Click Export

Export Filename with Hits

Your export should look something like this:

E:\folder\	FileOne.h	22.00 KB	17/09/2012 21:30:56	12	Keyword1	Keyword2
E:\folder\	FileTwo.cpp	22.00 KB	22/08/2012 17:30:17	4	Keyword1	Keyword2
E:\folder\	FileThree.h	2.00 KB	17/09/2012 20:50:19	1	Keyword1
E:\folder\	FileFour.h	2.00 KB	01/10/2012 18:15:34	1	Keyword2
E:\folder\	FileFive.H	28.00 KB	17/09/2012 20:43:00	1	KeyWord2
by (30.1k points)

You can do something similar with line-by-line output but this sounds more like what you're looking for. If you want something different please mock-up the required output in the question.

This is exactly what I was looking for actually. I was having trouble combining the hit script and the other, more verbose result scripts. Thanks!

...