Danvers High School teacher Colleen Ritzer was allegedly murdered by Philip Chism, a 14-year-old sophomore who was one of Ritzer’s math students.

A Salem District Court judge refused to unseal a search warrant affidavit filed in the investigation of the killing of Danvers High School teacher Colleen Ritzer, saying in a decision made public Friday that releasing details of the case could affect witnesses’ grand jury testimony and would be cruel to the victim’s family.

Ritzer was killed inside Danvers High School, allegedly by Philip Chism, a 14-year-old sophomore who was one of Ritzer’s math students.

The affidavit was filed by police as part of a request for a warrant to search Chism’s home.

Such affidavits usually outline the case being built by investigators to convince a judge that there is probable cause to believe that a search will find evidence of a crime.

Several news organizations, including The Boston Globe, sought to have the affidavit unsealed because authorities have released few details about the case, including what allegedly motivated Chism.

But Judge Michael C. Lauranzano said that releasing details of the case, which drew attention worldwide, could “effect/prejudice an ongoing criminal investigation by potentially influencing witnesses who are expected to testify before the grand jury.”

“Some of these witnesses are not equipped to handle the media attention that will be drawn to them as soon as their identities are revealed,” he wrote.

He also said he was acting to give the Ritzer family more time to cope with the shock of her death.

“I also find that the privacy interests of the victim’s family are implicated in this case,” the judge wrote. “. . . Release of this information now, without some additional time for the Ritzer family to come to terms with this horrific event, seems to me, to be unconscionable.”

Chism has been charged with first-degree murder as an adult and has pleaded not guilty at his arraignment in Salem District Court Oct. 23. He is being held without bail by the Department of Youth Services at the request of Essex County Sheriff Frank G. Cousins’ office.

During their investigation, State and Danvers police. along with Essex District Attorney Jonathan W. Blodgett’s office, executed the warrant, but then asked for the affidavit that explained the legal basis for the search to be sealed, along with other documents.

On Monday, lawyers for the Globe and other news organizations asked Lauranzano to unseal the affidavit and other records, a move opposed by Blodgett’s office and a lawyer for Ritzer’s family, who told the judge her family was still grieving the loss of the popular 24-year-old teacher.

Lauranzano, in his decision, extended the sealing of the affidavit to Nov. 22, the date that prosecutors have said they would finish presenting evidence to the grand jury.

Chism moved to Danvers this past summer from Tennessee with his mother and sisters. Friends and relatives have said he was unhappy about the move, but described him as friendly and sweet. He had made friends in Danvers and was a soccer standout.

A law enforcement official briefed on the investigation has told the Globe that Ritzer was stabbed and cut with a box cutter, possibly in a school bathroom where blood was found. Her body was recovered in the woods next to the high school.

Students have said that on the day she disappeared, Oct. 22, Ritzer had asked Chism to stay after class to help him prepare for a test.