Forum

JiFile for Joomla!

JIFile
JiFile is a component for Joomla! that allows you to index file contents (PDF, DOC, etc..) to perform searches in them.

Learn more...  Demo

JoomPhoto Mobile

JPhotoMobile
JoomPhoto Mobile is a component for Joomla! that allows you to share the photos from your Android device to your site Joomla.

Learn more...  Demo

iFile Framework

IFile
IFile is an open source framework written entirely in PHP, allows the indexing of textual content of a document (DOC, PDF, EXCEL, etc.) and a quick search within them.

Learn more...  Demo

Easy Language

EasyLanguage
Easy Language is a plugin for easy and immediate management of multilingual texts in every possible area of joomla, articles, components, modules, metadata, template, other components(example K2) etc.

Learn more...

Article Book Effect

Article Book Effect
View Joomla articles with the effect turns the page of a book. This plugin will display the contents of an article in Joomla as a real book or magazine, using all the benefits of HTML5

Learn more...  Demo

 

Passport photo

Passport photo
The most popular Android app that allows you to print photos cards for your documents with your Android smartphone, in a simple and intuitive way.

Learn more...

 

Crazy Shadow

Crazy Shadow
Crazy Shadow is the 3D fast-paced and fun puzzle Android game! Try to rotate and drag shapes in the position of their shadows without fail! Solve in succession all combinations of levels of the game.

Learn more...

 

Admin Countdown

Admin Countdown
Module for Joomla! 2.5 and 3.x displays in the administration part of the site, a timer with countdown of the time remaining in your session.

Learn more...  Demo

 
Welcome, Guest
Username: Password: Remember me

TOPIC: Ricerca Multi Termine

Ricerca Multi Termine 03 Apr 2012 17:40 #301

  • trullox
  • trullox's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
Ciao,
non mi è chiaro come posso fare una ricerca multitermine.
Utilizzo l'interfaccia Mysqli. I miei file sono indicizzati perciò nel database.
Nel form di ricerca inserisco delle parole e tramite un radiobutton decido se legarle con AND oppure OR.
La ricerca dei termini deve essere fatta su due campi della tabella dell'indice, e cioè: name e body.
In questo modo effettuo una ricerca sia sul nome del file che all'interno del contenuto del file.
La ricerca in OR la faccio in questo modo:
$ifileQueryRegistry = new IFileQueryRegistry();
foreach($parole as $parola){ //scorro i termini
	$ifileQueryRegistry->setQuery($parola, 'name', IFileQuery::MATCH_OPTIONAL);
	$ifileQueryRegistry->setQuery($parola, 'body', IFileQuery::MATCH_OPTIONAL);	
}
// definizione dell'ordinamento
$ifile->setSort('key', SORT_STRING, SORT_DESC);	
 
// chiamata al metodo di ricerca Multi-temine
$result = $ifile->query($ifileQueryRegistry);
le varie parole vengono legate con MATCH_OPTIONAL e l'OR viene fatto sia tra varie parole, sia tra i campi name e body.

La ricerca in AND è necessario che leghi in OR le due condizioni dei campi. Per me la ricerca è in OR se fatta su nome del file o contenuto, però deve essere in AND sui differenti termini.
L'avevo impostata così:
for($i=0; $i<count($parole); $i++){
	$ifileQueryRegistry_01 = new IFileQueryRegistry();
	$ifileQueryRegistry_01->setQuery($parole[$i], 'name', IFileQuery::MATCH_OPTIONAL);
	$ifileQueryRegistry_01->setQuery($parole[$i], 'body', IFileQuery::MATCH_OPTIONAL);
	$ifileQueryRegistry->setQuery($ifileQueryRegistry_01, null, IFileQuery::MATCH_REQUIRED);
}
a causa del null nell'ultima riga non funziona, però su qualche esempio l'avevo trovato scritto.
Mi date dei suggerimenti per realizzare ciò che voglio fare?

grazie
Andrea
The administrator has disabled public write access.

Re: Ricerca Multi Termine 03 Apr 2012 18:03 #302

  • trullox
  • trullox's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
d'altra parte non riesco neanche a capire perché questo codice sembra non restituire i risultati in AND.
foreach($parole as $parola){ //scorro i termini
	$ifileQueryRegistry->setQuery($parola, 'name', IFileQuery::MATCH_REQUIRED);
	//$ifileQueryRegistry->setQuery($parola, 'body', IFileQuery::MATCH_REQUIRED);
}
In pratica, avendo commentato la riga di ricerca sul body, dovrebbe trovare solo i file che contengono nel nome tutte le parole inserite. In realtà basta che ce ne sia una sola e il risultato viene restituito.

Inoltre: è possibile combinare più tipologie di ricerca? oltre questa multitermine mi piacerebbe mettere insieme anche quella wildcard con i caratteri speciali.
e poi: con la ricerca parser è possibile utilizzare la sintassi MYSQL FULLTEXT per ottenere tutti questi tipi di ricerca?

ciao
Andrea
Last Edit: 03 Apr 2012 18:09 by trullox.
The administrator has disabled public write access.

Re: Ricerca Multi Termine 03 Apr 2012 18:32 #303

  • Giampaolo
  • Giampaolo's Avatar
  • OFFLINE
  • Administrator
  • Posts: 465
  • Thank you received: 43
Ciao Andrea,
potresti inviarmi un caso d'uso reale per verificare il tuo problema?

Ad esempio potresti inviarmi anche tramite mail

info[at]isapp.it

un export di un paio di righe del DB e la configurazione di ifile in modo che possa fare anche io un paio di test.
con la ricerca parser è possibile utilizzare la sintassi MYSQL FULLTEXT per ottenere tutti questi tipi di ricerca?

utilizzando la ricerca parser è possibile scrivere direttamente le regole di ricerca FULL-TEXT di mysql.

Esempio:
// TEST Query PARSER
// Per l'utilizzo del metodo di ricerca PARSER si può utilizzare
// la sintassi di ricerca per le FULLTEXT di MySql
$search = "MATCH(body) AGAINST ('zend')";
// definizione dell'ordinamento
$ifile->setSort('key', SORT_STRING, SORT_DESC);		
// chiamata al metodo di ricerca Parser
$result = $ifile->queryParser($search);
If you like, if it was useful, consider a donation, Thanks
Se vuoi, se ti siamo stati utili, considera una donazione, Grazie
Help us by voting our extensions on Joomla.org:
JiFile
JoomPhoto Mobile
Easy Language
Last Edit: 03 Apr 2012 18:33 by Giampaolo.
The administrator has disabled public write access.