public MainSearchForm() { InitializeComponent(); TitleBoostBox.Enabled = false; AuthorBoostBox.Enabled = false; BibliBoostBox.Enabled = false; AbstractBoostBox.Enabled = false; LoadDatabaseButton.Enabled = false; TitleBoostBox.Text = "1.0"; AuthorBoostBox.Text = "1.0"; BibliBoostBox.Text = "1.0"; AbstractBoostBox.Text = "1.0"; PreviousButton.Hide(); NextButton.Hide(); SaveButton.Hide(); DisplayItenButton.Hide(); }
private void SearchButton_Click(object sender, EventArgs e) { // Check if the document has already indexed if (indexingState == true) { // Check if the query is empty if (!(QueryEnter.Text == "")) { // Determine whether the query should be remain orginal form if (PhraseFormCheckbox.Checked) { inputQuery = "\"" + QueryEnter.Text + "\""; } else { inputQuery = QueryEnter.Text; } searching = new SearchingClass(); stopwatch = new Stopwatch(); // Search the query against the index, the default return size is set to be 30 // retrieve the searching result TopDocs object stopwatch.Restart(); results = searching.SearchIndex(IndexingClass.luceneIndexDirectory, IndexingClass.analyzer, inputQuery, PhraseFormCheckbox.Checked, StemCheckBox.Checked, QueryExpansionCheckBox.Checked); stopwatch.Stop(); // Display Searching info if (QueryExpansionCheckBox.Checked && wordNet.IsLoaded) { if (SearchingClass.finalExpandedQueryList.Count == 0) { FinalQueryLabel.Text = "Final query: " + string.Join(", ", SearchingClass.queryList); } else { FinalQueryLabel.Text = "Final query: " + string.Join(", ", SearchingClass.finalExpandedQueryList); } } else { FinalQueryLabel.Text = "Final query: " + string.Join(", ", SearchingClass.queryList); } SearchingTimeLabel.Text = "Searching time: " + stopwatch.Elapsed.ToString(); TotalHitsLabel.Text = "Total hits: " + results.TotalHits; // Acquire the ranked documents and display the results and clean up searcher ranked_docs = searching.Get_doc(results); searching.ClearnUpSearcher(); DisplayResult(results, ranked_docs, displayBatch = 0); // Only show these button when totalhits is not zero if (results.TotalHits != 0) { DisplayItenButton.Show(); SaveButton.Show(); NextButton.Show(); } else { PreviousButton.Hide(); NextButton.Hide(); SaveButton.Hide(); DisplayItenButton.Hide(); } } else { MessageBox.Show("You need to specify your query"); } } else { MessageBox.Show("You need to do indexing before seaching"); } }