lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shad Storhaug <s...@shadstorhaug.com>
Subject RE: Visual Studio 2017 / Working Demo for Current Build
Date Wed, 31 May 2017 06:05:07 GMT
Thanks Todd.

Anthony,

The limitation of using Visual Studio 2015 is for *building* the Lucene.Net solution for .NET
Standard 1.5 within Visual Studio only. Fortunately, building is something end users rarely
have to do (and can be done via command line without Visual Studio). The limitation of Visual
Studio version is due to Microsoft's pre-release .NET Standard tooling not having support
for other versions of Visual Studio. There are now releases that have support for (only) Visual
Studio 2017, but until very recently they didn't work with NUnit3 Test Adapter in Visual Studio
2017. Not to mention, there are still some issues with the new tooling that make them not
support older versions of NuGet with pre-release version schemes.

Lucene 4.8.0-beta00004 is now available on NuGet: https://www.nuget.org/packages?q=lucene.net,
and can be installed into end user projects that are built using Visual Studio 2012 or higher.

See the following answer for updates for the LuceneNetDemo: https://stackoverflow.com/a/44061112

For now, you can use the Lucene 4.8.0 API documentation as a guide, although there are some
differences between the .NET and Java APIs, they are very similar. https://lucene.apache.org/core/4_8_0/


Thanks,
Shad Storhaug (NightOwl888)

-----Original Message-----
From: Todd Lucas [mailto:me@toddlucas.net] 
Sent: Wednesday, May 31, 2017 9:45 AM
To: dev@lucenenet.apache.org
Subject: RE: Visual Studio 2017 / Working Demo for Current Build

Hi Anthony,

The beta works fine on VS 2017 for me. Be sure to check ‘Include prerelease’ in NuGet.


 

Here is a sample that I was using for sanity checking the beta. I couldn’t find the original
source. You’ll find various versions of it if you search the Web. I just updated it to 4.8.

 

I created a .NET Core console app (netcoreapp1.1) and it worked fine.

 

using System;

 

using Lucene.Net.Analysis;

using Lucene.Net.Analysis.Standard;

using Lucene.Net.Documents;

using Lucene.Net.Index;

using Lucene.Net.Store;

using Lucene.Net.Util;

using Lucene.Net.Search;

 

namespace LuceneSample

{

    class Program

    {

        static void Main(string[] args)

        {

            //

            // 1. Initialize

            //

 

            Directory directory = FSDirectory.Open("LuceneIndex");

            Analyzer analyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);

            using (IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(LuceneVersion.LUCENE_48,
analyzer)))

            {

                //

                // 2. Add documents to the index.

                //

 

                Document doc = new Document();

                doc.Add(new StringField("id", "1", Field.Store.YES));

                doc.Add(new TextField("postBody", "abc 123", Field.Store.YES));

                writer.AddDocument(doc);

 

                doc = new Document();

                doc.Add(new StringField("id", "2", Field.Store.YES));

                doc.Add(new TextField("postBody", "xyz abc", Field.Store.YES));

                writer.AddDocument(doc);

 

                // Close the writer

                // writer.Flush();

                // writer.Close();

            }

 

            //

            // 3. Create the query

            //

 

            Query query = new TermQuery(new Term("postBody", "abc"));

 

            //

            // Step 4 – Pass the Query to the IndexSearcher

            //

 

            // Setup searcher

            DirectoryReader indexReader = DirectoryReader.Open(directory);

            var indexSearcher = new IndexSearcher(indexReader);

 

            // Do the search

            TopDocs hits = indexSearcher.Search(query, 10);

 

            //

            // 5. Iterate over the results

            //

 

            int results = hits.TotalHits;

            Console.WriteLine("Found {0} results", results);

            for (int i = 0; i < results; i++)

            {

                ScoreDoc scoreDoc = hits.ScoreDocs[i];

                int docId = scoreDoc.Doc;

                float score = scoreDoc.Score;

 

                Document doc = indexSearcher.Doc(docId);

                Console.WriteLine("Result num {0}, score {1}", i + 1, score);

                Console.WriteLine("ID: {0}", doc.Get("id"));

                Console.WriteLine("Text found: {0}" + Environment.NewLine, doc.Get("postBody"));

            }

        }

    }

}

 

From: Anthony Gatlin [mailto:anthony.gatlin@happycatfish.com] 
Sent: Tuesday, May 30, 2017 4:06 PM
To: dev@lucenenet.apache.org
Subject: Visual Studio 2017 / Working Demo for Current Build

 

The LuceneNET GitHub site says that only Visual Studio 2015 is supported for Lucene.NET 4.8
 builds and that Visual Studio 2017 is not supported. 

 

Can anyone provide any insight as to why Visual Studio 2017 is not supported and if this is
something that will soon be resolved?

 

What I am really wanting/needing to do is to actually get some kind of functioning demo that
works with the latest GitHub commit or MyGet build so that I can actually begin learning Lucene
in preparation for applying it on a .NET Standard project. 

It seems like the namespaces and methods have radically changed over the past few versions,
and I have been unable to find a single demo that actually works on 4.8 builds. 

 

Even Itamar Synershko's 4.8 demo ( https://channel9.msdn.com/Blogs/MVP-VisualStudio-Dev/LuceneNET-48-a-pre-release-introduction
 / https://github.com/synhershko/LuceneNetDemo ) appears to have issues. 

For starters, I was unable to perform a .NET restore on  the referenced Lucene.NET packages.
When I updated them with the latest version from MyGet, the build failed. 

There is an Analyzer called the HtmlStripAnalyzerWrapper.

using System.IO;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.CharFilters;
 
namespace LuceneNetDemo.Analyzers
{
    class HtmlStripAnalyzerWrapper : Analyzer
    {
        private readonly Analyzer _wrappedAnalyzer;
 
        public HtmlStripAnalyzerWrapper(Analyzer wrappedAnalyzer)
        {
            _wrappedAnalyzer = wrappedAnalyzer;
        }
 
        public override TokenStreamComponents CreateComponents(string fieldName, TextReader
reader)
        {
            
            return _wrappedAnalyzer.CreateComponents(fieldName, new HTMLStripCharFilter(reader));
        }
    }
}

 

The build is throwing an error here.

 

        public override TokenStreamComponents CreateComponents(string fieldName, TextReader
reader)
        {
            
            return _wrappedAnalyzer.CreateComponents(fieldName, new HTMLStripCharFilter(reader));
        }

 



 

It appears that the access modifiers for a method may have been changed from public to protected.
Being unfamiliar with Lucene, I am unsure how to workaround the issue.

 

Severity   Code Description     Project    File Line     Suppression State

Error CS0507     'HtmlStripAnalyzerWrapper.CreateComponents(string, TextReader)': cannot change
access modifiers when overriding 'protected internal' inherited member 'Analyzer.CreateComponents(string,
TextReader)'  LuceneNetDemo E:\Projects\LuceneNetDemo\LuceneNetDemo\Analyzers\HtmlStripAnalyzerWrapper.cs
    16   Active

 

Severity   Code Description     Project    File Line     Suppression State

Error CS1540     Cannot access protected member 'Analyzer.CreateComponents(string, TextReader)'
via a qualifier of type 'Analyzer'; the qualifier must be of type 'HtmlStripAnalyzerWrapper'
(or derived from it)  LuceneNetDemo E:\Projects\LuceneNetDemo\LuceneNetDemo\Analyzers\HtmlStripAnalyzerWrapper.cs
    19   Active

 

I am new to Lucene.NET. I want to learn it. I want to use it. I am absolutely thrilled about
the possibilities it offers. I am a little discouraged because there just do not seem to up-to-date
demos or much recent documentation.

If someone could point me in the right direction for getting a 4.8 demo working, I would much
appreciate it. I would also welcome links to any up-to-date documentation.

Many thanks!



 

 

 

Mime
View raw message