Skip to content

Commit 91ab948

Browse files
committed
Websites docs changes for dropping .NET 6
1 parent 6ed2050 commit 91ab948

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

websites/apidocs/apiSpec/core/Lucene_Net_Codecs.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Codecs API: API for customization of the encoding and structure of the index.
3131
* FieldInfos - see <xref:Lucene.Net.Codecs.FieldInfosFormat>
3232
* SegmentInfo - see <xref:Lucene.Net.Codecs.SegmentInfoFormat>
3333
* Norms - see <xref:Lucene.Net.Codecs.NormsFormat>
34-
* Live documents - see <xref:Lucene.Net.Codecs.LiveDocsFormat>
34+
* Live documents - see <xref:Lucene.Net.Codecs.LiveDocsFormat>
3535

3636
For some concrete implementations beyond Lucene's official index format, see the [Codecs module](../codecs/overview.html).
3737

3838
Codecs are identified by name through the <xref:Lucene.Net.Codecs.ICodecFactory> implementation, which by default is the <xref:Lucene.Net.Codecs.DefaultCodecFactory>. To create your own codec, extend <xref:Lucene.Net.Codecs.Codec>. By default, the name of the class (minus the suffix "Codec") will be used as the codec's name.
3939

4040
```cs
4141
// By default, the name will be "My" because the "Codec" suffix is removed
42-
public class MyCodec : Codec
42+
public class MyCodec : Codec
4343
{
4444
}
4545
```
@@ -49,7 +49,7 @@ public class MyCodec : Codec
4949
5050
To override the default codec name, decorate the custom codec with the <xref:Lucene.Net.Codecs.CodecNameAttribute>.
5151

52-
The <xref:Lucene.Net.Codecs.CodecNameAttribute> can be used to set the name to that of a built-in codec to override its registration in the <xref:Lucene.Net.Codecs.DefaultCodecFactory>.
52+
The <xref:Lucene.Net.Codecs.CodecNameAttribute> can be used to set the name to that of a built-in codec to override its registration in the <xref:Lucene.Net.Codecs.DefaultCodecFactory>.
5353

5454
```cs
5555
[CodecName("MyCodec")] // Sets the codec name explicitly
@@ -110,7 +110,7 @@ Codec.SetCodecFactory(services.GetService<ICodecFactory>());
110110
If your application is not using dependency injection, you can register a custom codec by adding your codec at start up.
111111

112112
```cs
113-
Codec.SetCodecFactory(new DefaultCodecFactory {
113+
Codec.SetCodecFactory(new DefaultCodecFactory {
114114
CustomCodecTypes = new Type[] { typeof(MyCodec) }
115115
});
116116
```
@@ -178,7 +178,7 @@ The <xref:Lucene.Net.TestFramework> library contains specialized classes to mini
178178
> See [Unit testing C# with NUnit and .NET Core](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-nunit) for detailed instructions on how to set up a class library to use with NUnit.
179179
180180
> [!NOTE]
181-
> .NET Standard is not an executable target. Tests will not run unless you target a framework such as `net6.0` or `net48`.
181+
> .NET Standard is not an executable target. Tests will not run unless you target a framework such as `net8.0` or `net48`.
182182
183183
Here is an example project file for .NET 8 for testing a project named `MyCodecs.csproj`.
184184

@@ -242,7 +242,7 @@ namespace ExampleLuceneNetTestFramework
242242
}
243243
```
244244

245-
The <xref:Lucene.Net.Index.BasePostingsFormatTestCase> class includes a barrage of 8 tests that can now be run using your favorite test runner, such as Visual Studio Test Explorer.
245+
The <xref:Lucene.Net.Index.BasePostingsFormatTestCase> class includes a barrage of 8 tests that can now be run using your favorite test runner, such as Visual Studio Test Explorer.
246246

247247
- TestDocsAndFreqs
248248
- TestDocsAndFreqsAndPositions

websites/site/quick-start/tutorial.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ However you are totally free to use [Visual Studio](https://visualstudio.microso
2323
First you must install the .NET Core SDK, if it's not already installed on your machine. The .NET Core SDK contains the .NET runtime, .NET Libraries and the .NET CLI. If you haven't installed it yet, download it from https://dotnet.microsoft.com/en-us/download and run the installer. It's a pretty straightforward process. I'll be using the **.NET 6.0 SDK** in this tutorial.
2424

2525
> [!NOTE]
26-
> The C# code we present **requires the .NET 6.0 SDK or later**. However, with a few simple modifications it can run on older SDKs including 4.x. To do that, the Program.cs file will need to have a namespace, Program class and a static void main method. See Microsoft docs [here](https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio?pivots=dotnet-5-0#code-try-3) for details. You will also need to add [braces to the using statements](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement#example).
26+
> The C# code we present **requires the .NET 6.0 SDK or later**. However, with a few simple modifications it can run on older SDKs including 4.x. To do that, the Program.cs file will need to have a namespace, Program class and a static void main method. See Microsoft docs [here](https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio?pivots=dotnet-5-0#code-try-3) for details. You will also need to add [braces to the using statements](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement#example).
2727
2828
## Download and Install PowerShell
2929
PowerShell is cross platform and runs everywhere .NET runs, so we will be using PowerShell for all of our command line work. If you don't already have PowerShell installed you can download and find instructions for installing it on Window, Unix or Mac on this [Installing PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell) page. In my examples I'm using PowerShell 7.2 but the specific version probably doesn't make a difference.
@@ -36,7 +36,7 @@ Let's use PowerShell now to verify that you have the .NET SDK with the .NET CLI
3636
This command will show the latest version of the .NET SDK installed and also show a list of all versions installed. If the .NET SDK is not installed this the command will return an error indicating the command was not found.
3737

3838
Below I show the top of the results for the `dotnet --info` command ran on my machine. You can see I'm using .NET SDK 6.0.200 on windows for this demo. In my case I had to scroll the screen up to see this info since I have many versions of the .NET SDK installed and it shows info on each version which scrolled the info about the latest version off the screen. Your latest version will likely be different than mine and perhaps you may be running on Unix or Mac. That's fine. But remember **you need .NET SDK 6 or later**. Or you need to modify the examples according to the note above.
39-
39+
4040
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/power-shell01.png'>
4141

4242
Now that our prerequisites are installed, we are ready to get started with our first example of using Lucene.NET.
@@ -57,15 +57,15 @@ In my case, since I'm on Windows, I'll create the directory using the GUI and us
5757
To create a C# console application project in the current directory, type this command in PowerShell:
5858

5959
`dotnet new console`
60-
60+
6161
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/power-shell03.png'>
6262

6363
### Add NuGet References
6464
We need to add references from our project to the Lucene.NET Nuget packages we need -- two separate packages in this case. Execute the first command in PowerShell: (Please note there are two dashes before prerelease not one.)
6565

6666
`dotnet add package Lucene.Net --prerelease`
6767

68-
68+
6969
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/power-shell04.png'>
7070

7171
And now add the 2nd Nuget package by executing this command in PowerShell:
@@ -77,14 +77,14 @@ And now add the 2nd Nuget package by executing this command in PowerShell:
7777
At this point, our directory has two files in it plus an obj directory with some additional files. We are mostly concerned with the lucene-example1.csproj project file and the Program.cs C# code file.
7878

7979
Our directory looks like this:
80-
80+
8181
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/directory-files-example1.png'>
8282

8383
### Viewing the Two Main files
8484
From here on out, you can use your favorite editor to view and edit files as we walk through the rest of the example. I'll be using Visual Studio 2022 on Windows, but you could just as easily use VIM, Visual Studio Code or any other editor and even be doing that on Ubuntu on a Raspberry Pi if you like. Remember, Lucene.NET and the .NET framework both support a wide variety of platforms.
8585

8686
Below is what the project file looks like which we created using the dotnet CLI. Notice that it contains package references to the two Lucene.NET Nuget packages we specified.
87-
87+
8888
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/example1.csproj.png'>
8989

9090
Here is that file's contents:
@@ -94,7 +94,7 @@ Here is that file's contents:
9494
9595
<PropertyGroup>
9696
<OutputType>Exe</OutputType>
97-
<TargetFramework>net6.0</TargetFramework>
97+
<TargetFramework>net8.0</TargetFramework>
9898
<RootNamespace>lucene_example1</RootNamespace>
9999
<ImplicitUsings>enable</ImplicitUsings>
100100
<Nullable>enable</Nullable>
@@ -110,7 +110,7 @@ Here is that file's contents:
110110

111111

112112
Now let's look at the `Program.cs` file that got generated. It looks like:
113-
113+
114114
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/program01.png'>
115115

116116

@@ -122,7 +122,7 @@ If you are using Visual Studio or Visual Studio Code you can just hit F5 to run
122122
`dotnet run`
123123

124124
This will run the project from the PowerShell current directory after it does a restore of the Nuget packages for the project.
125-
125+
126126
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/hello-world-example1.png'>
127127

128128
And there you go. You can see in the window above that we get the output we expected.
@@ -144,15 +144,15 @@ using OpenMode = Lucene.Net.Index.OpenMode;
144144
using Document = Lucene.Net.Documents.Document;
145145

146146
// Specify the compatibility version we want
147-
const LuceneVersion luceneVersion = LuceneVersion.LUCENE_48;
147+
const LuceneVersion luceneVersion = LuceneVersion.LUCENE_48;
148148

149149
//Open the Directory using a Lucene Directory class
150150
string indexName = "example_index";
151151
string indexPath = Path.Combine(Environment.CurrentDirectory, indexName);
152152

153153
using LuceneDirectory indexDir = FSDirectory.Open(indexPath);
154154

155-
//Create an analyzer to process the text
155+
//Create an analyzer to process the text
156156
Analyzer standardAnalyzer = new StandardAnalyzer(luceneVersion);
157157

158158
//Create an index writer
@@ -195,7 +195,7 @@ Console.WriteLine($"Title of first result: {title}");
195195
```
196196

197197
> [!WARNING]
198-
> As mentioned earlier, if you are not running .NET 6.0 SDK or later you will need to modify the above code in the following two ways: 1) Program.cs file will need to have a namespace, Program class and a static void main method. See Microsoft docs [here](https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio?pivots=dotnet-5-0#code-try-3) for details; and 2) you will need to add [braces to the using statements](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement#example).
198+
> As mentioned earlier, if you are not running .NET 6.0 SDK or later you will need to modify the above code in the following two ways: 1) Program.cs file will need to have a namespace, Program class and a static void main method. See Microsoft docs [here](https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio?pivots=dotnet-5-0#code-try-3) for details; and 2) you will need to add [braces to the using statements](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement#example).
199199
200200
### Code Walkthrough
201201
Before running the code let's talk about what it does.
@@ -204,7 +204,7 @@ The using declarations at the top of the file specify the various namespaces we
204204

205205
```c#
206206
// Specify the compatibility version we want
207-
const LuceneVersion luceneVersion = LuceneVersion.LUCENE_48;
207+
const LuceneVersion luceneVersion = LuceneVersion.LUCENE_48;
208208

209209
//Open the Directory using a Lucene Directory class
210210
string indexName = "example_index";
@@ -215,7 +215,7 @@ using LuceneDirectory indexDir = FSDirectory.Open(indexPath);
215215

216216
Then in the next block we create an `IndexWriter` that will use our `LuceneDirectory`. The `IndexWriter` is a important class in Lucene.NET and is used to write documents to the Index (among other things).
217217

218-
The `IndexWriter` will create our subdirectory for us since it doesn't yet exist and it will create the index since it also doesn't yet exist. By using `OpenMode.CREATE` we are telling Lucene.NET that we want to recreate the index if it already exists. This works great for a demo like this since every time the console app is ran we will be recreating our LuceneIndex which means we will get the same output each time.
218+
The `IndexWriter` will create our subdirectory for us since it doesn't yet exist and it will create the index since it also doesn't yet exist. By using `OpenMode.CREATE` we are telling Lucene.NET that we want to recreate the index if it already exists. This works great for a demo like this since every time the console app is ran we will be recreating our LuceneIndex which means we will get the same output each time.
219219

220220
```c#
221221
//Create an index writer
@@ -281,12 +281,12 @@ Console.WriteLine($"Title of first result: {title}");
281281

282282
### View of the Project.cs file with Our Code
283283
The `Program.cs` file should now look something like this in your editor:
284-
284+
285285
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/example1-new-program.cs.png'>
286286

287287
### Run the Lucene.NET Code
288288
So now you can hit F5 in Visual Studio or VS Code or you can execute `dotnet run` in PowerShell to see the code run and to see if it outputs what we expect.
289-
289+
290290
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/run-example1.png'>
291291

292292
And in the above screenshot we can see that the 2nd time we executed `dotnet run` (ie. after we modified the Program.cs file, out output says:
@@ -297,7 +297,7 @@ Title of first result: Powerful open source search library for .NET
297297
This is exactly what we would expect.
298298

299299

300-
### Conclusion - Example 1
300+
### Conclusion - Example 1
301301
While this example is not particularly complicated, it will get you started. It provides fully working code that uses Lucne.NET that you now understand.
302302

303303
When looking at this code it's pretty easy to imagine how one might use a while loop instead of inline code for adding documents and how one could perhaps add 10,000 documents (or a million documents) instead of just three. And it's pretty easy to imagine how one would add several fields per document rather then just two.
@@ -310,7 +310,7 @@ Then move onto the next example that demonstrates full text search.
310310
We are going to create a console application that uses Lucene.NET to index three documents that each have two fields and then the app will search those docs on a certain field doing an full text search and output some info about the results.
311311

312312
This example assumes you did Example 1 so:
313-
1. You already have the .NET SDK installed,
313+
1. You already have the .NET SDK installed,
314314
2. You already have PowerShell installed,
315315
3. You know how to create a C# console application project,
316316
4. You are familiar with the Example 1 code.
@@ -337,7 +337,7 @@ Technically the line above to `dotnet add package Lucene.Net --prerelease` is no
337337

338338
### View the Project Files
339339
Just like in the prior example the project folder will have two files and an obj directory with some files. Now use your favorite editor to view the project's .proj file. It should look like this:
340-
340+
341341
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/example2.csproj.png'>
342342

343343
Here is that file's contents:
@@ -347,7 +347,7 @@ Here is that file's contents:
347347
348348
<PropertyGroup>
349349
<OutputType>Exe</OutputType>
350-
<TargetFramework>net6.0</TargetFramework>
350+
<TargetFramework>net8.0</TargetFramework>
351351
<RootNamespace>lucene_example2</RootNamespace>
352352
<ImplicitUsings>enable</ImplicitUsings>
353353
<Nullable>enable</Nullable>
@@ -364,12 +364,12 @@ Here is that file's contents:
364364
```
365365

366366
And the `Program.cs` file that got generated will look like this again:
367-
367+
368368
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/program02.png'>
369369

370370
### Run the App
371371
If you are using Visual Studio or VS Code you can hit F5 to run the app. I will execute `dotnet run` in PowerShell to run it:
372-
372+
373373
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/hello-world-example2.png'>
374374

375375
And we can see it output Hello World! Just as it did in Example 1.
@@ -398,7 +398,7 @@ string indexPath = Path.Combine(Environment.CurrentDirectory, indexName);
398398

399399
using LuceneDirectory indexDir = FSDirectory.Open(indexPath);
400400

401-
// Create an analyzer to process the text
401+
// Create an analyzer to process the text
402402
Analyzer standardAnalyzer = new StandardAnalyzer(luceneVersion);
403403

404404
//Create an index writer
@@ -455,7 +455,7 @@ As you might guess we have an additional using declaration `using Lucene.Net.Que
455455

456456
We are creating a `LuceneDirectory` and `IndexWriter` the same way and we are adding the same documents and then committing them. All stuff we saw in Example1. Also in this example we get our index reader and searcher the same way we did in the last example.
457457

458-
**But** the way we query back documents in this example is different.
458+
**But** the way we query back documents in this example is different.
459459

460460
This time around, instead of using a `TermQuery` to do an exact match search, have these two lines of code:
461461

@@ -466,7 +466,7 @@ Query query = parser.Parse("open source");
466466

467467
These lines allow us to create a query that will perform a full text search. This type of search is similar to what you are use to when doing a google or bing search.
468468

469-
What we are saying in these two lines is that we want to create a query that will search the `title` field of our documents and we want back document that contain "open source" or just "open" or just "source" and we want them sorted by how well they match our "open source" query.
469+
What we are saying in these two lines is that we want to create a query that will search the `title` field of our documents and we want back document that contain "open source" or just "open" or just "source" and we want them sorted by how well they match our "open source" query.
470470

471471
So when the line of code below runs, Lucene.NET will score each of our docs that match the query and return the top 3 matching documents sorted by score.
472472

@@ -491,17 +491,17 @@ for (int i = 0; i < topDocs.TotalHits; i++)
491491

492492
### View of the Project.cs file with Our Code
493493
The `Program.cs` file should now look something like this in your editor:
494-
494+
495495
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/example2-new-program.cs.png'>
496496

497497
### Run the Lucene.NET Code
498498
So now you can hit F5 in Visual Studio or VS Code or you can execute `dotnet run` in PowerShell to see the code run and to see if it outputs what we expect.
499-
499+
500500
<img src='https://lucenenet.apache.org/images/quick-start/tutorial/run-example2.png'>
501501

502-
If you go back and review the contents of the `title` field for each document you will see the output from running the code does indeed return the only two documents that that contain "open source" in the title field.
502+
If you go back and review the contents of the `title` field for each document you will see the output from running the code does indeed return the only two documents that that contain "open source" in the title field.
503503

504-
### Conclusion - Example 2
504+
### Conclusion - Example 2
505505
In this Example we saw Lucene.NET's full text search feature. But we only scratched the surface.
506506

507507
It's the responsibility of the analyzer to tokenize the text and it's the tokens that are stored in the index as terms. In our case we used the `StandardAnalyzer` which removes punctuation, lower cases the text so it's not case sensitive and removes stop words (common words like "a" "an" and "the").

0 commit comments

Comments
 (0)