Jump to content

mike2

Members
  • Posts

    73
  • Joined

  • Last visited

mike2's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. OK I will take all of that into consideration. In your opinion is still possible to do this using the Swish-e search engine? Here is the Swish-e link Swish-e.org
  2. Yes I have. I have read both these documents and so far they haven't been much help to me. http://devzone.zend.com/1591/indexing-web-content-with-php-and-swish-e/ http://swish-e.org/docs/swish-search.html#phrase_searching
  3. To whom it may concern: I have PHP code that I am trying to improve upon. I want to fix it so that when I put a dash next to a word, the word that is next to a dash is excluded. I also want to see if it is possible, what would I have to change in my code so that when I search for words or phrases within PDF documents, that I get exactly what I want. Whenever I have the Exact Phrase radio button enabled, and I type in the phrase Oil Gas Company, three PDF appear, however when I open the links of those PDF documents to search for that phrase, that exact phrase is not there so since it is not there I want to know what I would have to do to fix it so that the 0 matches found appears on my screen? also When it comes to using the dash what I want know is, is it possible to have something like Tax credit -appraisal in the search box and when either the Exact Phrase or the Any Phrase radio is selected it will do the function of both radio buttons but at the same time exclude the word appraisal in its search? Any Phrase meaning of course it will search for either words in the phrase and bring up PDFs that have either results or both. I ask these questions because whenever I type into the my search box bank and loans -money while the Exact Phrase radio button is highlighted it is only suppose to return PDF documents that have that exact phrase but without the word money in them. Is this possible with my code. Is this possible with my code? attached with this message is my php code. Any help would be greatly appreciated. Finalsearchcode2.txt
  4. I will learn from this. Thank you for the advice.
  5. Here is my answer to your question: This is where I am getting the result from my Swish query: <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (score: <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?><br /> To the best of my knowledge this code displays my PDF files as links and they open up when you click them. Is that what you are asking me?
  6. I am testing my current code. I got the results as shown above where the paginated links just keep showing up in separate results.
  7. Hello everyone. I have some code that I need some assistance with. By the way I am using CentOS 6.5 on my Linux server. Here is my current code: <html> <head></head> <body> <?php if (!isset($_POST['q'])) { ?> <img src="/wvb-logo-slogen.png" border="0" /> //code for logo <h2>Search</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <input type="text" name="q" size="30" /> </form> <?php } else { ?> <img src="/wvb-logo-slogen.png" border="0" /> //code for logo <h2>Search Results</h2> <?php try { // create object // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e'); $swish = new Swish('/var/www/html/pdf2/index.swish-e'); // get and run query from command-line $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); ?> Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'. <?php // iterate over result set // print details for each match while($r = $result->nextResult()) { ?> <p> <?php echo $r->swishreccount; ?> <strong> <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (score: <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?><br /> <?php $file = '/var/www/html/active_colist.csv'; $fh = fopen($file, 'r'); $companies = array(); $row = fgetcsv($fh, 1024); // ignore header while ($row = fgetcsv($fh, 1024)) { $companies[$row[0]] = array('company' => $row[1], 'country' => $row[3]); //changed line } fclose($fh); //Split a filename by . $filenames = explode(".", $r->swishdocpath); //get 3 chars from $filenames to $country $wvb_number = substr($filenames[1],1,12); $country = substr($filenames[1],1,3); echo 'Country: '.$companies[$wvb_number]['country']."<br />"; //echo 'Country Name: '.$country."<br />"; //$filenames[2] = explode(".", $r->swishdocpath); $year = substr($filenames[2],0,4); echo 'Year: '.$year."<br />"; //$filenames = explode(".", $r->swishdocpath); //$wvb_number = substr($filenames[1],1,12); echo 'WVB Number: '.$wvb_number."<br />"; echo 'Company Name: '.$companies[$wvb_number]['company']; ?> </p> //Suggested Pagination code. <?php ///////////////FILLING ARRAY WITH DUMMY DATA//////////////////// $key = array(); for($i=0; $i<200; $i++) { //fill array data $key[] = "num = ".$i; } //////////////////////////////////////////////////////////////// /////////////////////START OF ARRAY PAGINATION CODE///////////////////// $ptemp="http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $pt=explode('&',$ptemp); if (strpos($ptemp,'pageno')) array_pop($pt); $pt=implode('&',$pt); $ptemp=$pt; $array=$key; // REPLACE $KEY WITH YOUR ARRAY VARIABLE $page = $_REQUEST['pageno']; $currentpage = isset($page) ? (integer)$page : 1; $numperpage = 10; //NUMBER OF RECORDS TO BE DISPLAYED PER PAGE $total = count($array); $numofpages = ceil($total / $numperpage); //TOTAL NUMBER OF PAGES if(isset($array)) { if (($currentpage > 0) && ($currentpages <= $numofpages)) { //STARTING LOOP FOR ARRAY DATA $start = ($currentpage-1) * $numperpage; for($i=$start;$i<=($numperpage+$start-1);$i++) { ///////////PLACE YOUR CODE HERE////////////////////////// echo $array[$i] .' '; //////////////////////////////////////////////////////// } } } if ($currentpage != 1) { //GOING BACK FROM PAGE 1 SHOULD NOT BET ALLOWED $previous_page = $currentpage - 1; $previous = '<a href="'.$ptemp.'?pageno='.$previous_page.'"> <</a> '; } $pages = ''; for ($a=1; $a<=$numofpages; $a++) { if ($a == $currentpage) $pages .= $a .'</u> '; else $pages .= '<a href="'.$ptemp.'?pageno='.$a.'" >'. $a .'</a> '; } $pages = substr($pages,0,-1); //REMOVING THE LAST COMMA (,) if ($currentpage != $numofpages) { //GOING AHEAD OF LAST PAGE SHOULD NOT BE ALLOWED $next_page = $currentpage + 1; $next = ' <a href="'.$ptemp.'?pageno='.$next_page.'"> ></a>'; } echo ' '. $previous . $pages . $next; //PAGINATION LINKS /////////////////////END OF ARRAY PAGINATION CODE///////////////////// ?> <?php } } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?> </body> </html> As you can see from the code above when I implemented that code into my script I was able to get it to display but only after the </p> marker. When I did that I got the following results. Results: Found 736 match(es) for 'test'. 1 ./ITA000030192.2013.A.00.L.12.31.PDF (score: 1000) ./ITA000030192.2013.A.00.L.12.31.PDF Country: Italian Republic (Italy) Year: 2013 WVB Number: ITA000030192 Company Name: BEGHELLI num = 0 num = 1 num = 2 num = 3 num = 4 num = 5 num = 6 num = 7 num = 8 num = 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > 2 ./ITA000030164.2013.A.00.L.12.31.PDF (score: 976) ./ITA000030164.2013.A.00.L.12.31.PDF Country: Italian Republic (Italy) Year: 2013 WVB Number: ITA000030164 Company Name: CREDITO EMILIANO num = 0 num = 1 num = 2 num = 3 num = 4 num = 5 num = 6 num = 7 num = 8 num = 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > 127 ./IND000102048.2012.A.00.E.03.31.PDF (score: 457) ./IND000102048.2012.A.00.E.03.31.PDF Country: Year: 2012 WVB Number: IND000102048 Company Name: num = 0 num = 1 num = 2 num = 3 num = 4 num = 5 num = 6 num = 7 num = 8 num = 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > 128 ./NLD000030064.2013.A.00.E.12.28.PDF (score: 457) ./NLD000030064.2013.A.00.E.12.28.PDF The results page shows that there are 736 matches. There are currently 5000 PDF files in the /var/www/html/pdf2 directory. What I am trying to accomplish in terms of pagination is twofold. First get the above page links to display on the top and bottom of the page and only display 10 results at a time on each page. Second have the links working correctly so that they can go to the correct results. Can this be accomplished with the above pagination code where it states //Suggested pagination code? Do I need to change my layout? Furthermore I was also told that I should focus on the following lines of code: <?php ///////////////FILLING ARRAY WITH DUMMY DATA//////////////////// $key = array(); for($i=0; $i<200; $i++) { //fill array data $key[] = "num = ".$i; } as well as the result variable $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); What would I need to change in these two areas in order to get what it is that I am trying to accomplish. Sorry for the large post. Any assistance would be greatly appreciated.
  8. To answer your question honestly I am worried that my output is not going to come out correctly. I am concerned it is going to come out with lines skipped. Also are you sure that I need to rearrange this code? Can't I just incorporate this code somewhere?
  9. Here in lies my problem with changing the layout of the code: I have never used php coding before to do a project like this. This project was assigned to me for work and I have mostly been getting help from people who do know php. I e-mailed this one particular individual to see if he would be willing to do it for me and if so would he charge me because to be quite honest with you I am not sure I am going to have this completed by the June 20th date. Would it be wrong of me to send you the complete details of what I am trying to accomplish as well as ask if either you or someone you know whom you could recommend would be willing to do it for me? I am in way over my head here. I have never done anything like this before and I am getting desperate to get this project completed because I don't want to get in trouble for not having this completed on time.
  10. The user would not be allowed to change the PDF files. However PDF files would be constantly uploaded to the site. I have 5000 PDF files indexed at the moment.
  11. How would I do that though? Would that code be at the very beginning before my search results or after?
  12. Okay. I will try doing that but my question is would this negatively affect my Swish-e search results?
  13. Hi Everyone, I have a question about pagination. I have this code that I would like to incorporate into my php file. This is said code that will be incorporated: try { // Find out how many items are in the table $totalItems = $databaseHandle->query(' select count(*) from tableName ')->fetchColumn(); // Set how many items per page to display $limit = 10; // find how many pages are needed $totalPages = ceil($totalItems / $limit); // Find out which page we are on $currentPage = min($totalPages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 1, 'min_range' => 1, ), ))); // Calculate the offset for the query $offset = ($page - 1) * $limit; // Some information to display to the user $start = $offset + 1; $end = min(($offset + $limit), $total); // "back" link $prevlink = ($page > 1) ? '<a href="?page=1" title="First page">«</a> <a href="?page=' . ($currentPage - 1) . '" title="Previous page">‹</a>' : '<span class="disabled">«</span> <span class="disabled">‹</span>'; // "forward" link $nextlink = ($page < $pages) ? '<a href="?page=' . ($page + 1) . '" title="Next page">›</a> <a href="?page=' . $totalPages . '" title="Last page">»</a>' : '<span class="disabled">›</span> <span class="disabled">»</span>'; // Display the paging information echo '<div id="paging"><p>', $prevlink, ' Page ', $currentPage, ' of ', $totalPages, ' pages, displaying ', $start, '-', $end, ' of ', $totalItems, ' results ', $nextlink, ' </p></div>'; // Get the results. Paged query $stmt = $databaseHandle->prepare(' select * from tableName order by name limit :limit offset :offset '); // Bind the query params $stmt->bindParam(':limit', $limit, PDO:: PARAM_INT); $stmt->bindParam(':offset', $offset, PDO:: PARAM_INT); $stmt->execute(); // Results? if ($stmt->rowCount() > 0) { $stmt->setFetchMode(PDO::FETCH_ASSOC); $iterator = new IteratorIterator($stmt); // Display the results foreach ($iterator as $row) { echo '<p>', $row['name'], '</p>'; } } else { echo '<p>No results could be displayed.</p>'; } } catch (Exception $e) { echo '<p>', $e->getMessage(), '</p>'; } and this is what is in my php file: <html> <head></head> <body> <?php if (!isset($_POST['q'])) { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <input type="text" name="q" size="30" /> </form> <?php } else { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search Results</h2> <?php try { // create object // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e'); $swish = new Swish('/var/www/html/pdf2/index.swish-e'); // get and run query from command-line $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); ?> Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'. <?php // iterate over result set // print details for each match while($r = $result->nextResult()) { ?> <p> <?php echo $r->swishreccount; ?> <strong> <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (score: <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?><br /> <?php $file = '/var/www/html/active_colist.csv'; $fh = fopen($file, 'r'); $companies = array(); $row = fgetcsv($fh, 1024); // ignore header while ($row = fgetcsv($fh, 1024)) { $companies[$row[0]] = array('company' => $row[1], 'country' => $row[3]); //changed line } fclose($fh); //Split a filename by . $filenames = explode(".", $r->swishdocpath); //get 3 chars from $filenames to $country $wvb_number = substr($filenames[1],1,12); $country = substr($filenames[1],1,3); echo 'Country: '.$companies[$wvb_number]['country']."<br />"; //echo 'Country Name: '.$country."<br />"; //$filenames[2] = explode(".", $r->swishdocpath); $year = substr($filenames[2],0,4); echo 'Year: '.$year."<br />"; //$filenames = explode(".", $r->swishdocpath); //$wvb_number = substr($filenames[1],1,12); echo 'WVB Number: '.$wvb_number."<br />"; echo 'Company Name: '.$companies[$wvb_number]['company']; //echo 'Country: '.$companies[$wvb_number]['country']; ?> </p> <?php } } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?> </body> </html> My question is what would be the best way incorporate this into my php file so that I am able to display a limit number link by page so that not all of the results are listed on the same page? If that is even possible.
  14. I changed some code around and I was able to resolve it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.