Inspecting Lucene.NET index with Luke want to replicate NHibernate.Search view - c#

I am trying to put together an index using terms, which I specify as a comma separated list. I want to replicate the display in Luke as seen here:
http://ayende.com/Blog/archive/2009/05/03/nhibernate-search-again.aspx
But my index value just shows as a single field with the comma separate list value. For example:
Tags term,anotherterm
When I search my index, it will return results if I search with "term" but will not return anything if I search with "anotherterm"
I thought the indexing process would break the comma separate list apart into separate values but this does not seem to be the case.
Anyone got any ideas?
Thanks

The collection to index is ISet<T> and I suspect that T is a type with [Indexed] attribute and has a property Name marked with [Field] attribute.

This was answered as part of this question:
Lucene.NET search index approach

Related

c# convert datagridview id to collection names

I'm having problems with a datagridview. I'm trying to export the row selection of datagridview1 in a array to be used in a chart in the same solution. I need to convert those id's to the actual collection name. I tried with a enum list to convert the id to the collection name, but compiler gives me a error so in the end I used a case switch. Is enum the correct way to go to convert an id to a collection name or should I follow a different road?
e.Graphics.DrawLine(Pen, position1, position2(Enum.GetName(typeof(collectioname),idofcollectioname), positionx2, positiony2));
I am not sure if I got your question but,
I need to convert those id's to the actual collection name
If you mean by Id some value that can be one of Limited Set of values, the answer is YES, you can use an Enum.
But if the Id something else, the answer is NO, you can't use it.

How to ArrayList Object From a Selected Index in Listbox C#

So I have an arraylist that will display data to a listbox. Then, the user can select an entry in the listbox. From there, I need to be able to grab whatever entry they select. I'm using VS 2010.
I have been trying
tempArray.Insert(0, myarray.IndexOf(mylistbox.SelectedIndex);
All this is doing is giving me the actual index number and not the contents of the index. I'm not sure how to index the arraylist to get the object that is contained at that index.
And yes, I know that I should be using List objects, but it is for class and we have yet to be taught list objects.
As the name suggests .IndexOf() will return an index from the array.
Array.IndexOf Method
This is obviously not what you want.
What you should look at is using the SelectedItem instead of the SelectedIndex.
That way, you can access the object directly and insert it into your list. One thing to remember is that SelectedItem will return an Object. This means that it will have to be cast to the type that you expect to be using.
Also, are you wanting to constantly insert items to the top of the list or does it not matter. If you can append it to the end of the list, try using .Add(yourObject).
If these are actual arrays you are working with, shouldn't you be able to to access what's in the array by using the [ ] syntax? i.e.
myArray[myListBox.SelectedIndex]
1) Dont use ArrayList... that's an old class. Use List<T> instead.
2) Have you tried ListBox.SelectedItem ? That seems a bit simpler...

Getting Value at Selected Indices in C# ASP.net ListBox

I am trying to get the value at selected indicies in a ListBox using ASP.net C#
MakeListBox.SelectionMode = ListSelectionMode.Multiple;
int [] indicies= MakeListBox.GetSelectedIndices();
I am going to dynamically building a select statement for a database query to an SQLDataSource. What I had hoped to be able to do was get all the selected indexes go through a loop to for the array that it returns and add each value at the specified index to a string.
I have looked through this and this but can't find what is needed to do what I have talked about.
Basically I am looking for the opposite of the IndexOf command. Or a technique that would have the same results.
It's not clearly obvious when looking at the ListBox control properties, but this is the best way to do it:
foreach(ListItem li in MakeListBox.Items)
{
if(li.Selected)
{
// Append to your string list
}
}

How to fetch entries starting with the given string from a SQL Server database?

I have a database with a lot of words to be used in a tag system. I have created the necessary code for an autocomplete box, but I am not sure of how to fetch the matching entries from the database in the most efficient way.
I know of the LIKE command, but it seems to me that it is more of an EQUAL command. I get only the words that looks exactly like the word I enter.
My plan is to read every row, and then use C#'s string.StartsWith() and string.Contains() functions to find words that may fit, but I am thinking that with a large database, it may be inefficient to read every row and then filter them.
Is there a way to read only rows that starts with or contains a given string from SQL Server?
When using like, you provide a % sign as a wildcard. If you want strings that start with Hello, you would use LIKE 'Hello%' If you wanted strings with Hello anywhere in the string, you would use LIKE '%Hello%'
As for efficiency, using Like is not optimal. You should look into full text search.
I know of the LIKE command, but it seems to me that it is more of an EQUAL command. I get only the words that looks exactly like the word I enter.
That's because you aren't using wildcards:
WHERE column LIKE 'abc%'
...will return rows where the column value starts with "abc". I'll point out that when using wildcards, this is the only version that can make use of an index on the column... er column.
WHERE column LIKE '%abc%'
...will return rows where the column value contains "abc" anywhere in it. Wildcarding the left side of a LIKE guarantees that an index can not be used.
SQL Server doesn't natively support regular expressions - you have to use CLR functions to gain access to the functionality. But it performs on par with LIKE.
Full Text Search (FTS) is the best means of searching text.
You can also implement a StartWith functionality using the following statements:
LEFT('String in wich you search', X) = 'abc'
CHARINDEX('abc', 'String in wich you search') = 1
'String in wich you search' LIKE 'abc%'
Use the one wich performs best.
You can use CONTAINS in T-SQL, but I'm pretty sure you have to have to be using full-text indexing for the table involved in your query.
Contains
Getting started with Full-Text Search

Get all lucene values that have a certain fieldName

To solve this problem I created a new Lucene index where all possible distincted values of each field are indexed seperatly.
So it's an index with a few thousand docs that have a single Term.
I want to extract all the values for a certain term. For example, I would like all values that have the fieldName "companyName".
Defining a WildcardQuery is off course not a solution. Neither is enumerating ALL fields and only saving the ones with the correct fieldName.
This should work (I take it it still is in C#)
IndexReader.Open(/* path to index */).Terms(new Term("companyName", String.Empty));

Categories